php无法看到图片

时间:2013-02-04 20:17:29

标签: php html css

这是我的php:

     <html>
 <head>
</head>
<body>
<?php 
include ('source\visuose\navigation.php');`enter code here`
include('source\visuose\social.php')
?>
</body>
 </html>

导航:

    <html xmlns="http://www.w3.org/1999/xhtml", lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../../css/style.css" />

社交:

<body>



  <div id="facebook"> 
   <a href="http://www.facebook.com" target="_blank">
   <img src="../../images/facebook-logo.jpg" width="81" height="36" />
     </a>

   </div><!--facebook ends-->




</body>
</html>

为什么,在运行php时我看不到图片? 只有一个空白框,但我可以按下它们并转到我的href?

3 个答案:

答案 0 :(得分:2)

如果没有看到你的文件结构就无法确定,但这就是它的样子;

您的“主”php位于服务器根目录/main.php中,并包含source\visuose\social.php。由于social.php包含,因此浏览器认为它是/main.php的一部分。

social.php为浏览器提供了相对路径../../images/facebook-logo.jpg,但由于浏览器认为它是/main.php包含它,它将相对于该文件导航,而不是source\visuose\social.php。当浏览器导航您的相对路径时,它指向没有用的东西。

您还应该检查生成的页面的来源,现在您有多个html和body标签以奇怪的方式相互包装。

答案 1 :(得分:1)

它必须与图像的路径有关。在firefox中你只需要右键单击图像并选择显示图像。要查看它指向的位置(也就是来自)并检查图像的预期URL是什么?

然后相应地修复图像路径。

答案 2 :(得分:0)

这不是PHP问题 修复图像的src

    <img src="../../images/facebook-logo.jpg" width="81" height="36" />

它会起作用