|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-10-24 11:42 UTC] info at its-mieger dot de
Description:
------------
Integer values are converted to strings by mb_convert_variables. But variable types should be kept
Test script:
---------------
$x = ["a" => 1];
mb_convert_variables("UTF-8", "ISO-8859-15", $x);
var_dump($x);
Expected result:
----------------
array(1) {
["a"]=>
int(1)
}
Actual result:
--------------
array(1) {
["a"]=>
string(1) "1"
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 15:00:02 2025 UTC |
Well yeah: it's as if you wrote $x["a"] = mb_convert_encoding($x["a"], "UTF-8", "ISO-8859-15"); I would expect mb_convert_variables() to work on strings (or recursively on arrays and objects) and not to silently pass through values of a non-conforming type. It's like how substr("123", 0, 1) is the string "1" and not the integer 1 (let alone 123). Type casting like that is standard behavior for PHP. Does that make sense?