3v4l.org

run code in 500+ PHP versions simultaneously
<?php $input = '🧪 test'; $encodings = ['utf-8', 'utf-16', 'utf-32']; foreach ($encodings as $to) { var_dump([ 'to' => $to, 'mb_substr' => mb_substr($input, 3, 4, $to), 'iconv_substr' => iconv_substr($input, 3, 4, $to), 'substr' => substr($input, 3, 4), 'substr+utf8_encode' => substr(utf8_encode($input), 3, 4), 'substr+utf8_decode' => substr(utf8_decode($input), 3, 4) ]); }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Function utf8_encode() is deprecated in /in/I3lr4 on line 13 Deprecated: Function utf8_decode() is deprecated in /in/I3lr4 on line 14 array(6) { ["to"]=> string(5) "utf-8" ["mb_substr"]=> string(3) "est" ["iconv_substr"]=> string(3) "est" ["substr"]=> string(4) "� te" ["substr+utf8_encode"]=> string(4) "�§�" ["substr+utf8_decode"]=> string(3) "est" } Warning: iconv_substr(): Wrong encoding, conversion from "utf-16" to "UCS-4LE" is not allowed in /in/I3lr4 on line 11 Deprecated: Function utf8_encode() is deprecated in /in/I3lr4 on line 13 Deprecated: Function utf8_decode() is deprecated in /in/I3lr4 on line 14 array(6) { ["to"]=> string(6) "utf-16" ["mb_substr"]=> string(4) "es?" ["iconv_substr"]=> bool(false) ["substr"]=> string(4) "� te" ["substr+utf8_encode"]=> string(4) "�§�" ["substr+utf8_decode"]=> string(3) "est" } Warning: iconv_substr(): Wrong encoding, conversion from "utf-32" to "UCS-4LE" is not allowed in /in/I3lr4 on line 11 Deprecated: Function utf8_encode() is deprecated in /in/I3lr4 on line 13 Deprecated: Function utf8_decode() is deprecated in /in/I3lr4 on line 14 array(6) { ["to"]=> string(6) "utf-32" ["mb_substr"]=> string(0) "" ["iconv_substr"]=> bool(false) ["substr"]=> string(4) "� te" ["substr+utf8_encode"]=> string(4) "�§�" ["substr+utf8_decode"]=> string(3) "est" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.35 ms | 1646 KiB | 4 Q