如何使用 href 调用 php 中的图像?
我有一些代码,使用 php,我希望它调用图像而不是当前调用的内容(即“echo bloginfo('name');”)。然而,遗憾的是我不懂 PHP,并且不知道如何使用下面发布的“a href”来做到这一点。谁能帮我打电话到/images/logo.png?非常感谢!
<h1><a href="<?php echo get_settings('home'); ?>"><?php echo bloginfo('name'); ?></a></h1>
I have a bit of code that, using php, I want it to call in an image rather than what it is currently calling in (which is 'echo bloginfo('name');). However, I am sadly PHP illiterate and have no idea how to do this with the 'a href' posted below. Could anyone help me call to /images/logo.png? Many thanks in advance!
<h1><a href="<?php echo get_settings('home'); ?>"><?php echo bloginfo('name'); ?></a></h1>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
添加图像的标签是
![]()
在src
属性上,您需要编写所需图像的 url(在您的情况下/images/logo.png
) 因此,替换您粘贴的代码考虑到您现在使用的图像的路径是相对路径(相对于需要图像的文档),因此您可能想要改为使用绝对网址。
The tag for add images is
<img src="">
on thesrc
attribute you need to write the url of the image you want (in your case/images/logo.png
) so, replacing the code you pastedTake into account that the path to the image you are using now is a relative one (relative to the document requiring the image) so you probably want to have the absolute url instead.
...放置在网页的开头,靠近顶部以及 PHP/JavaScript 的其余部分:
...在此放置所有 HTML...
基本上,您可以有一个名为“image_name”的变量可以是任何东西。
如果您希望 HREF 链接区域也是一个可以更改的变量,只需执行以下操作:
然后...
...place at the beginning of you webpage, near the top with the rest of your PHP/JavaScript:
...In this are you place allof your HTML...
Basically, you can have a variable named 'image_name' that you can have be anything.
If you wanted the HREF link area to be a variable that could be changed as well, just do this:
Then...
get_settings()
函数的返回值是什么? ==>名字的图片?我认为这段代码没问题,但你应该检查函数的返回值。
What is the return of
get_settings()
function? ==> name's Image?I think this code is OK, but you should check the return value of your function.