|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-03-12 03:03 UTC] hufeng1987 at gmail dot com
Description: ------------ I am using php 5.4, i got a trouble with htmlspecialchars, htmlentities. php 5.4 default charset is utf-8. i thought htmlspecialchars, htmlentities may be using utf-8 as default encoding, but even i configured default_charset in my php.ini , the htmlspecialchars and htmlentities still stupid using utf-8. this is a bad expirence, my project is a little big, htmlspecialchars using every where, almost 3 million called. i had no chance to specified encoding by hand. add encoding to each call of htmlspecialchars and htmlentities not possible, it is a huge change for me . for another solution, why not php let htmlspecialchars using encoding by php.ini settings? is it a better way? is it friendly to users? sorry for my bad english. Test script: --------------- <?php $string = '<pre><p>我是测试</p></pre>'; echo htmlspecialchars($string); echo htmlspecialchars($string, NULL, 'GB2312'); Expected result: ---------------- htmlspecialchars should using charset defined by php.ini default_charset. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
I was wondering if someone could enlighten me by explaining why this: htmlspecialchars($str, ENT_QUOTES, "ISO-8859-1"); ... would be considered any more secure than something like this: ini_set("html.default_charset", "ISO-8859-1"); htmlspecialchars($str, ENT_QUOTES); Thank you!