如何在PHP中添加href链接? [英] How to add a href link in PHP?

查看:166
本文介绍了如何在PHP中添加href链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP的新手,正在尝试快速进行网站更新.

I'm very new to PHP and trying to make a site update on the fly.

我需要更新代码,以便链接将直接定向到www.otherwebsite.com.目前,该链接指向当前网站的RSS Feed.

I need to update the code so that the link will direct to www.otherwebsite.com. Currently the link directs to the current websites RSS feed.

这是原始的div:

<div style="float:right;">
<a href="<?php echo url::site(); ?>feed/"><img src="<?php echo url::file_loc('img'); ?>media/img/icon-feed.png" style="vertical-align: middle;" border="0"></a>

我需要更改它以指向www.someotherwebsite.com.看起来很简单.这是我尝试过的:

I need to alter this to point to www.someotherwebsite.com. It looked simple enough. Here is what I tried:

<div style="float:right;">
    <a href="<?php echo www.someotherwebsite.com"><img src="<?php echo url::file_loc('img'); ?>media/img/twitter.png" style="vertical-align: middle;" border="0"></a>

那从来没有奏效,相反,我收到了有关进行此编辑的那一行的错误消息.

That never worked, instead I received an error message concerning the line where I had made this edit.

我将如何更新?

推荐答案

好像您错过了几个结束标记,并且外部URL的前面应该没有"http://".另外,您应该将样式移至外部样式表,而不要使用嵌入式样式.

Looks like you missed a few closing tags and you nshould have "http://" on the front of an external URL. Also, you should move your styles to external style sheets instead of using inline styles.

.box{
  float:right;
}
.box a img{
  vertical-align: middle;
  border: 0px;
}

<div class="box">
    <a href="<?php echo "http://www.someotherwebsite.com"; ?>">
        <img src="<?php echo url::file_loc('img'); ?>media/img/twitter.png" alt="Image Decription">
    </a>
</div>

如其他评论所述,根据您的确切设置,使用直接HTML可能会更容易.

As noted in other comments, it may be easier to use straight HTML, depending on your exact setup.

<div class="box">
    <a href="http://www.someotherwebsite.com">
        <img src="file_location/media/img/twitter.png" alt="Image Decription">
    </a>
</div>

这篇关于如何在PHP中添加href链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆