我正在使用 Laravel 4,以及 PHP 和 MySQL。 一切都在 UTF-8 中
我的数据库中存储了博客标题,如下所示:
This is an "example" post title
现在在我的网站上,我有使用 alt
的图片title
属性。
当我 echo
我的博客标题,我得到类似的东西:
<img src="image.jpg" alt="This is an "example" post title" />
这当然很糟糕。
我尝试了以下方法:
{{ html_entity_decode($blog_title, ENT_QUOTES, 'UTF-8') }}
但是好像没什么作用。我错过了什么?
我希望标题显示如下:This is an "example" post title
最佳答案
我使用的是 5.7 laravel 版本。以下解决方案解决了我的问题:
<p>{!! $pa_full_desc !!}</p>
这里 $pa_full_desc 有虚拟的 html 内容,例如。
<p>In lobortis pharetra mattis. Morbi nec nibh iaculis, <a href="#">bibendum augue a</a>, ultrices nulla. Nunc velit ante, lacinia id tincidunt eget, faucibus nec nisl.</p>
这对我有用。感谢您提出这个问题。
关于php - Laravel html_entity_decode 使用 UTF-8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25643894/