I have a site with index.php in the root folder, images in /img , and overview.php in /content . I have a sidebar.php file that is included in both index.php and overview.php . How should I refer to /img/image.gif if I include a link in each file?
The location of image.gif changes relative to the location of the file that references it. Using /img/image.gif in sidebar.php will work in index.php, but it fails for the file located at /content/overview.php. The only solution that I can see is to either include a seperate sidebar.php in each subdirectory, or include an /img directory in every sub-directory.
The best suggestion that I can find is to use the <base
> html tag as suggested here:
Change relative link paths for included content in PHP
Ancak, aynı bağlantı, SamGoody ", artık düzgün desteklenen Internet Explorer bu sürümü 7. yana." <base
> etiketi önerir
Ben eylem bir ders işlemeden önce konuyla ilgili bazı bilgiler istiyorum.
Teşekkürler.
EDIT: Ben aşağıda yanlış yaklaşımı kullanıyorum ".. /"
Example-
root/index.php:
...
<link rel="stylesheet" type="text/css" href="style.css" />
<title>title</title>
</head>
<body>
<?php include('include/header.php'); ?>
<?php include('include/menu.php'); ?>
...
root/include/header.php:
...
<div id="header">
<span class="fl"><img src="img/dun1.png"/></span><span class="fr"><img src="img/dun2.png"/></span>
...
root/content/overview.php:
...
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" />
<title>Overview</title>
</head>
<body>
<?php include('../include/header.php'); ?>
<?php include('../include/menu.php'); ?>
...