Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which charset considering functions changed from PHP5.2 to PHP5.4

When having a file saved in ISO-8859-1 and using the command

echo "test: ".htmlspecialchars("äöü");

The return will be only "test: ".

This is because the standard charset for htmlspecialchars changed to UTF-8 in PHP5.4. You need to explicitly set the charset:

echo "test: ".htmlspecialchars("äöü", ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');

Are there any other functions in PHP5.4, that will not work properly anymore, if you do not set the charset?

like image 432
R_User Avatar asked Nov 14 '22 01:11

R_User


1 Answers

htmlentities seems to be another function that was changed: http://de3.php.net/manual/de/migration54.other.php

The migration guide from PHP 5.2->5.3 does not give any more functions that changed the default charset: http://de3.php.net/manual/de/migration53.php

So probably it is only htmlspecialchars() and htmlentities

Anyway, I think those two should definitely go to the "Backward Incompatible Changes"-list http://de3.php.net/manual/de/migration54.incompatible.php

like image 109
R_User Avatar answered Jan 20 '23 02:01

R_User