【问题标题】:a href refers to site itself + link instead of the link itselfa href 指的是网站本身 + 链接而不是链接本身
【发布时间】:2015-10-20 11:09:10
【问题描述】:

在 Codeigniter 中,我有一个包含网站链接的数据库。 每个项目(事件)都有一个指向事件页面的链接。

<a href="<?php echo $event->LinkSite; ?>">Site</a>

但它并没有转到所需的站点,而是将链接添加到现有 url,如下所示:http://web.site.local/index.php/evenementen/www.referedsite.com 检查 html 代码时,它显示以下内容:

<a href="www.referedsite.com">Site</a>

有谁知道如何让它转到 www.referedsite.com 而不是让它添加到现有链接中?

【问题讨论】:

  • 你的链接来自数据库?

标签: php html codeigniter hyperlink href


【解决方案1】:

试试

<a href="<?php echo 'http://' . $event->LinkSite; ?>">Site</a>

【讨论】:

    【解决方案2】:

    在codeignitor中你可以使用

    echo anchor('', 'Site');
    // Prints: <a href="http://example.com">Site</a>
    

    阅读CI Anchor

    【讨论】:

      【解决方案3】:

      你需要把 HTTP://

      <a href="http://www.referedsite.com">Site</a>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-01
        • 2012-10-29
        相关资源
        最近更新 更多