Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Weird behaviour when changing the different php.ini settings to influence the default mb_internal_encoding() encoding.
<?php
echo "\n\nPHP: " . phpversion()."\n";
echo "Default: " . mb_internal_encoding()."\n";
echo "Old value of default_charset: ".ini_set("default_charset", "ASCII")."\n";
echo "when default_charset is set to ASCII: " . mb_internal_encoding()."\n";
echo "Old value of internal_encoding: ".ini_set("internal_encoding", "ASCII")."\n";
echo "when internal_encoding is set to ASCII: " . mb_internal_encoding()."\n";
echo "Old value of mbstring.mb_internal_encoding: ". ini_set("mbstring.internal_encoding", "ASCII")."\n";
echo "when mbstring.internal_encoding is set to ASCII: " . mb_internal_encoding()."\n";
/** Output:
PHP: 7.0.21-1~ubuntu16.04.1+deb.sury.org+1
Default: UTF-8
Old value of default_charset: UTF-8
when default_charset is set to ASCII: UTF-8
Old value of internal_encoding:
when internal_encoding is set to ASCII: UTF-8
Old value of mbstring.mb_internal_encoding:
when mbstring.internal_encoding is set to ASCII: ASCII
*/
/** Bash version for easy c&p
vagrant@atmo:~$ php -r '
echo "\n\nPHP: " . phpversion()."\n";
echo "Default: " . mb_internal_encoding()."\n";
echo "Old value of default_charset: ".ini_set("default_charset", "ASCII")."\n";
echo "when default_charset is set to ASCII: " . mb_internal_encoding()."\n";
echo "Old value of internal_encoding: ".ini_set("internal_encoding", "ASCII")."\n";
echo "when internal_encoding is set to ASCII: " . mb_internal_encoding()."\n";
echo "Old value of mbstring.mb_internal_encoding: ". ini_set("mbstring.internal_encoding", "ASCII")."\n";
echo "when mbstring.internal_encoding is set to ASCII: " . mb_internal_encoding()."\n";
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment