3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* Two identical strings: "®" (c2 ae). They are built at runtime because literals cannot get the flag. */ $plain = implode('', ["\xC2", "\xAE"]); $flagged = implode('', ["\xC2", "\xAE"]); var_dump(bin2hex(mb_str_split($plain)[0])); /* Marks $flagged as valid UTF-8 without changing its bytes */ mb_check_encoding($flagged, 'UTF-8'); /* DOCOMO writes "®" as ee 9c b6 */ var_dump(bin2hex(mb_substr($plain, 0, 1, 'UTF-8-Mobile#DOCOMO'))); var_dump(bin2hex(mb_substr($flagged, 0, 1, 'UTF-8-Mobile#DOCOMO'))); ?>
Output for 8.2.0 - 8.2.34, 8.3.0 - 8.3.1
string(4) "c2ae" string(4) "c2ae" string(4) "c2ae"
Output for 8.3.2 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
string(4) "c2ae" string(6) "ee9cb6" string(6) "ee9cb6"

preferences:
27.87 ms | 1139 KiB | 9 Q