使用HTML Helper创建图像链接

前端之家收集整理的这篇文章主要介绍了使用HTML Helper创建图像链接前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用Laravel 4的 HTML帮助程序创建一个图像链接.但它似乎并没有真正起作用.我有这行代码 @H_403_2@{{ HTML::link("#",HTML::image("img/logo.png","logo") ) }}

但这只是输出这样的strin:

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

怎么会.??

解决方法

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

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

@H_403_2@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>'; }

生成此源代码

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

猜你在找的HTML相关文章