Phphtml entity character conversion what functions can php convert html entity symbol 'é?
Php has tried several functions.
Reply to discussion (solution)
I don't know how you do it.
First, let's give you a list of HTML entities supported by php.
Foreach (get_html_translation_table (HTML_ENTITIES) as $ k => $ v ){
Echo ord ($ k). '=>'. $ v. PHP_EOL;
}
Then you can do it yourself.
Agree upstairs
It seems that this symbol is supported. which function should be used for conversion?
I don't know how you do it.
First, let's give you a list of HTML entities supported by php.
Foreach (get_html_translation_table (HTML_ENTITIES) as $ k => $ v ){
Echo ord ($ k). '=>'. $ v. PHP_EOL;
}
Then you can do it yourself.
echomb_convert_encoding("é", "UTF-8", "HTML-ENTITIES"); //é
Good. what if there are many such characters in an article that need to be converted? I can't change them one by one. Is there a simpler way?
PHP code
Echo mb_convert_encoding ("& eacute;", "UTF-8", "HTML-ENTITIES ");
// É
Do you want this?
Foreach (get_html_translation_table (HTML_ENTITIES) as $ k => $ v ){
$ Str = str_replace ($ v, mb_convert_encoding ($ v, "GBK", "HTML-ENTITIES"), $ str );
}
Good. what if there are many such characters in an article that need to be converted? I can't change them one by one. Is there a simpler way? Reference reply on the 4th floor:
PHP code
Echo mb_convert_encoding ("& amp; eacute;", "UTF-8", "HTML-ENTITIES ");
// É
Html_entity_decode
$ Text = mb_convert_encoding ($ text, "UTF-8", "HTML-ENTITIES ");
Or you. Solve the problem that has plagued me for a long time. You can fall asleep tonight.
$ Text = mb_convert_encoding ($ text, "UTF-8", "HTML-ENTITIES ");
There is still a problem. The characters are converted clean. However, common characters such as spaces do not work.
For example
$ Str = 'ban "√ "';
$ Str = mb_convert_encoding ($ str, "GBK", "HTML-ENTITIES ");
Echo $ str;
$ Text = mb_convert_encoding ($ text, "UTF-8", "HTML-ENTITIES ");
Html_entity_decode ');