简体   繁体   中英

in PHP using special characters

In PHP I am trying to write a string in a file.

hi hello world<Data="Text">Vtt</Text> How are you

but writing this is showing the string with special characters such as &lt; and &gt;

$a = htmlentities($m_str_val);
$str_final = html_entity_decode($a);

How can this can be solved?

The htmlentities() function converts all applicable entities into their HTML equivalent.

' will become &#039;

< will become &lt; '

> will become &gt;

etc.

If you don't want the conversion to happen, don't use htmlentities(). Simply write $m_str_val to the file as-is.

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