character encoding - What's the difference between these 2 functions in PHP? -


mb_convert_encoding($html,'html-entities','utf-8');  htmlentities($html); 

what's difference between 2 functions above?

from php.net:

mb_convert_encoding — convert character encoding

this converts passed string specified encoding type. in example, utf-8. html passed not escaped. link

htmlentities — convert applicable characters html entities

this means string passed in have of html tags escaped.

for example:

<b>this some</b> <a href="http://php.net">html</a> 

will become

&lt;b&gt;this some&lt;/b&gt; &lt;a href="http://php.net"&gt;html&lt;/a&gt; 

when echoed screen, instead of being interpreted html. link 2


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -