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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里