[英]How to use include() to include image in <img src=
我需要HTML和PHP的帮助。 如何在<img src"">
使用include()?
例:
<?php
some code here
$page_banner = $_SERVER['DOCUMENT_ROOT'].'/img/page-banner.png';
some code here
?>
some code here
<img src=<?php include($page_banner); ?>>
但不幸的是,它不起作用。 希望您能理解我的意思。
对不起,英语不好。 Google帮了我。
您不需要\\想要在这里简单地包括它。
<img src='<?php echo $page_banner; ?>'>
src =是图像的URI
您可以将include()
用于文件,而不用于变量。 因此,只需使用不include()
的变量。
<img src='<?php echo $page_banner; ?>'>
不要忘记图像路径周围的引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.