[英]PHP - Not able display images which src comes from database
<i><img src="<?php echo $path ;?>" alt="<?php echo $path;?>" style="width:250px;height:250px;"></i>
这里$path
是到单独驱动器上该映像的绝对路径(E:/)
As you are running your script from the server, cause a PHP script. 从服务器运行脚本时,请生成PHP脚本。 Lets say you have your script in the directory named myFirstScript
, inside this folder you have a file named script.php
where you wrote your this code. 假设您将脚本放在名为myFirstScript
的目录中,在此文件夹中,有一个名为script.php
的文件,您在其中编写了此代码。
<i><img src="<?php echo $path ;?>" alt="<?php echo $path;?>" style="width:250px;height:250px;"></i>
So the question is what is the $path
here? 所以问题是这里的$path
是什么? OK, don't worry, because you are using this $path
to the src of an image so it is a image file. 好的,不用担心,因为您正在使用此$path
到图像的src,因此它是图像文件。 And this image file must in the same directory named myFirstScript
. 并且此映像文件必须位于名为myFirstScript
的同一目录中。 Say you have the image named image.jpg
. 假设您有一个名为image.jpg
的图像。 so your path is: $path = 'image.jpg';
所以你的路径是: $path = 'image.jpg';
Example: 例:
<?php $path = 'image.jpg';?>
<i><img src="<?php echo $path ;?>" alt="<?php echo $path;?>" style="width:250px;height:250px;"></i>
Real time Example: 实时示例:
<?php $path = 'http://placehold.it/350x150';?>
<i><img src="<?php echo $path ;?>" alt="<?php echo $path;?>" style="width:250px;height:250px;"></i>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.