index.php
我在根文件夹中有一个站点,其中/img
的图像overview.php
位于/content
. 我有一个sidebar.php
包含在index.php
和中的文件overview.php
。/img/image.gif
如果我在每个文件中都包含一个链接,我应该如何引用?相对于引用它的文件
位置的更改位置。
使用in将在 中工作,但对于位于 的文件则失败。
我能看到的唯一解决方案是在每个子目录中包含一个单独的目录,或者在每个子目录中包含一个目录。
我能找到的最佳建议是按照此处的建议使用 > HTML 标记:image.gif
/img/image.gif
sidebar.php
index.php
/content/overview.php
sidebar.php
/img
<base
更改 PHP 中包含内容的相对链接路径
但是,在同一个链接中,SamGoody 建议<base
> 标签is no longer properly supported in Internet Explorer, since version 7.
在采取行动之前,我想对此事有一些了解。
谢谢。
编辑:我在下面使用了错误的方法"../"
例子-
根/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'); ?>
...
根/包含/header.php:
...
<div id="header">
<span class="fl"><img src="img/dun1.png"/></span><span class="fr"><img src="img/dun2.png"/></span>
...
根/内容/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'); ?>
...