如何使用php回显图像 [英] How to echo an image with php
本文介绍了如何使用php回显图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在试图回复我的'_images'文件夹中的图片,但如果我写下面的代码,它只适用于我的网站:
I'm trying to echo an image from my '_images' folder, but if I write the following code, it is only for my website:
echo '<img src="http://mywebsite.com/mytheme/wp-content/themes/my theme/_images/project3image1.jpg">';
我已将其更改为此,所以当其他人使用我的主题时,它会将它们带到自己的网站目录:
I've changed it to this so when someone else uses my theme, it takes them to their own website directory:
echo '<img src="<?php bloginfo('stylesheet_directory'); ?>/_images/project3image1.jpg">';
但是这个代码一定有问题我把它放到预览我的网站它给了我这个错误:
But there must be something wrong with this code when I put that and preview my website it gives me this error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/content/32/9825632/html/bomb/wp-content/themes/bomb/header.php on line 101
我是一个php noob,所以这可能是一个明显的错误!
I'm a php noob so it's probably an obvious mistake!
推荐答案
你已经在php / echo out了,所以你不需要使用php标签:
You are already in php / echoing things out, so you do not need to use php tags:
echo '<img src="' . bloginfo('stylesheet_directory') . '/_images/project3image1.jpg">';
这篇关于如何使用php回显图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文