图像不';从.php页面加载时不显示

图像不';从.php页面加载时不显示,php,html,image,Php,Html,Image,当我单独打开“anypage.html”时,图像显示正常。但是,当我尝试使用php从动态加载打开它时,它没有打开。页面的其余部分完全正常 index.php在中动态打开我的其他页面,这些其他页面是.htm 我尝试使用.php页面来显示图像,认为将php与html结合会带来一些问题,但什么都没有 因此,简而言之,我尝试在使用php加载的.htm页面中显示图像 index.php <body> <div id="header"> //some navigation &

当我单独打开
“anypage.html”
时,图像显示正常。但是,当我尝试使用php从动态加载打开它时,它没有打开。页面的其余部分完全正常

index.php
中动态打开我的其他页面,这些其他页面是
.htm

我尝试使用
.php
页面来显示图像,认为将php与html结合会带来一些问题,但什么都没有

因此,简而言之,我尝试在使用php加载的
.htm
页面中显示图像

index.php

<body>
<div id="header">
    //some navigation
</div>

<div id="content">
<?php
$pages_dir = 'Templates';
if(!empty($_GET['p'])) {
    $Templates = scandir($pages_dir, 0);
    unset($Templates[0], $Templates[1]);

    $p = $_GET['p'];

    if(in_array($p.'.htm', $Templates)) {
        include($pages_dir.'/'.$p.'.htm');
    }
    else {
        echo '<font size="+2">Sorry, not found.</font>';
    }

}
else {
    include($pages_dir.'/main_page.htm');
}
?>
</div>

<div id="footer">
</div>

</body>

试试这个:背景图像:url('/images/anyimg.png');你能给我们看看生成的HTML代码吗?这将非常有用。HTML页面和PHP文件在同一个目录中吗?如果没有,您需要将图像的src属性更改为PHP文件所在的图像路径。@FireCrakcer37哈哈,谢谢!成功了!真不敢相信这么简单。现在这是有道理的,但我想很容易认为路径应该是
anypage.htm
所在的位置,而不是
index.php
index.php
是分离的。其余页面位于模板内,
“anyimg”
位于/Templates/images中。
<style>
td.something {
    background-image:url(images/anyimg.png);
}
</style>


<table>
<tr>
    <td class="something"> ... </td>
</tr>
</table>