加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

使用HTML Helper创建图像链接

发布时间:2020-12-14 16:38:34 所属栏目:资源 来源:网络整理
导读:我正在尝试使用Laravel 4的 HTML帮助程序创建一个图像链接.但它似乎并没有真正起作用.我有这行代码 {{ HTML::link("#",HTML::image("img/logo.png","Logo") ) }} 但这只是输出这样的strin: img src="http://localhost/worker/public/img/logo" alt="Logo"
我正在尝试使用Laravel 4的 HTML帮助程序创建一个图像链接.但它似乎并没有真正起作用.我有这行代码
{{ HTML::link("#",HTML::image("img/logo.png","Logo") ) }}

但这只是输出这样的strin:

<img src="http://localhost/worker/public/img/logo" alt="Logo">

怎么会.??

解决方法

你可能需要:
<a href="#">{{ HTML::image("img/logo.png","Logo") }}</a>

因为,link()使用实体来转义标题:

public function link($url,$title = null,$attributes = array(),$secure = null)
{
    $url = $this->url->to($url,array(),$secure);

    if (is_null($title) or $title === false) $title = $url;

    return '<a href="'.$url.'"'.$this->attributes($attributes).'>'.$this->entities($title).'</a>';
}

生成此源代码:

"<a href="#">&lt;img src=&quot;http://localhost/img/logo.png&quot; alt=&quot;Logo&quot;&gt;</a>"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读