htmlspecialchars_PHP tutorial about PHP5.4

WBOY
Release: 2016-07-13 17:52:19
Original
905 people have browsed it

Today the project was upgraded to php5.4, gbk encoding, and the string converted by htmlspecialchars is empty, which is very frustrating

To solve it, add encoding. HTMLspecialchars is used in so many places. It is really troublesome to change it. It seems that I will have to encapsulate it myself in the future.


UPGRADING said
[html]
- the default character set for htmlspecialchars() and htmlentities() is
now UTF-8. In previous versions it was ISO-8859-1. Note that changing
Your output charset via the php.ini default_charset directive does not
affect htmlspecialchars/htmlentities unless you are passing "" (an
empty string) as the encoding parameter to your htmlspecialchars/htmlentities
calls.

It is also mentioned in the manual

[html]
string htmlspecialchars ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = 'UTF-8' [, bool $double_encode = true ]]] )

[html]
Defines encoding used in conversion. If omitted, the default value for this argument is ISO-8859-1 in versions of PHP prior to 5.4.0, and UTF-8 from PHP 5.4.0 onwards.


Author: xanxng

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478129.htmlTechArticleToday the project was upgraded to php5.4, gbk encoding, and the string converted by htmlspecialchars was empty. It was frustrating and solved. Let’s add coding, htmlspecialchars is used in so many places, it’s really troublesome to change it...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!