dping1968 2013-03-16 22:44
浏览 119
已采纳

如何在PHP中添加href链接? [关闭]

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

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.

Here is the original 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>

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.

How would I update this?

  • 写回答

4条回答 默认 最新

  • doutou6803 2013-03-16 22:54
    关注

    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>
    

    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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误