3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function gdr_encode($val) { return base_convert(strval($val), 10, 16); } function gdr_decode($val) { return base_convert(strval($val), 64, 10); } $vals = array(0, 1, 99, 100, 255, 256, 999, 1000, 9999, 10000, 65535, 65536, 99999, 100000, 999999, 1000000, 4294967295, 4294967296); foreach ($vals as $val) { $enc = json_encode(gdr_encode($val)); $dec = json_encode(gdr_decode($enc)); $val = json_encode($val); if (strlen($enc) > strlen($val)) { echo "$enc $val WORSE\n"; } else if (strlen($enc) == strlen($val)) { echo "$enc $val EQUAL\n"; } else { echo "$enc $val\n"; } }
based on 1QF10
Output for 5.2.0 - 7.1.0
Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "0" 0 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "1" 1 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "63" 99 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "64" 100 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "ff" 255 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "100" 256 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "3e7" 999 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "3e8" 1000 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "270f" 9999 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "2710" 10000 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "ffff" 65535 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "10000" 65536 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "1869f" 99999 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "186a0" 100000 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "f423f" 999999 WORSE Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "f4240" 1000000 EQUAL Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "ffffffff" 4294967295 EQUAL Warning: base_convert(): Invalid `from base' (64) in /in/KPLqq on line 8 "100000000" 4294967296 WORSE
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/KPLqq on line 13
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_encode() in /in/KPLqq on line 13
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_encode() in /in/KPLqq on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_encode() in /in/KPLqq on line 13