Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

agahi's avatar
Level 1

html_entity_decode not working.

I have extracted some text from mysql and the HTML charactes appear to be encoded so for example "<" has changed to "<". I want them to act as html characters for example: "<p>" converted to a working paragraph tag. I tried:

{{ html_entity_decode($text) }}

And

{{ htmlspecialchars_decode($text) }}

but they are not working. Probably worth mentioning that the text is normal on the database and it is throughtout the Laravel process that characters get encoded.

0 likes
2 replies
agahi's avatar
Level 1

OK it got more interesting. If inside view page I do it like this there will be no problem and html wouldn't be encoded - ie "<" remains "<" and wouldn't be converted to "& lt;" -

<?php
echo  $article->text;
?>

but it will be encode if I do it like this - ie "<" would be converted to "&lts;"

    {{ $article->text}}

I could just simply try this solution but that would defy the purpose of moving to Laravel.

Please or to participate in this conversation.