Home > Blockchain >  Echo a variable contains html tags from MYSQL
Echo a variable contains html tags from MYSQL

Time:07-17

I added a short formated text into my MYSQL variable "my_text" using the function FILTER_SANITIZE_FULL_SPECIAL_CHARS and I saved this text like this:

Text in MYSQL:

<p style="text-align: justify;"><span style="color: rgb(224, 62, 
45);">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy 
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam 
voluptua.</span></p>

If I fetch this variable and I try to php echo it on the front end, somehow these tags do not work, because the php echo puts this full string among quotation marks and I see this:

<p style="text-align: justify;"><span style="color: rgb(224, 62, 45);">Lorem ipsum dolor 
sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore 
et dolore magna aliquyam erat, sed diam voluptua.</span></p>

Why does it not work?

Thank you for your help!

CodePudding user response:

If you wish to convert sanitized HTML back to actual HTML, have a look at

html_entity_decode()

https://www.php.net/manual/en/function.html-entity-decode.php

  • Related