简体   繁体   中英

How to properly bold the decoded data in PHP

I am posting data to database which requires that I encode it. To this effect I used htmlentities() and to decode it am using html_entity_decode()

Here is my issue: My problem is that the decoded result is does not bold the "Helloworld" rather it shows back the Helloworld surrounded by the HTML bold tags.

$str = "<b>Hello world</b>";

echo $en = htmlentities(htmlentities($str));

echo "<br>decode<br>";

echo  $result = html_entity_decode($en);

由于您要编码两次,因此您也必须解码两次。

echo html_entity_decode(html_entity_decode($en));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM