3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Use descriptive replacement mb_substitute_character('none'); $badAscii = 'Invalid input: ' . chr(0x81); print mb_convert_encoding($badAscii, 'UTF-8', 'ASCII'); print "\n"; $utf8 = 'UTF-8 that is not in ASCII: €'; print mb_convert_encoding($utf8, 'ASCII', 'UTF-8');
Output for 8.1.32, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.13
Invalid input: UTF-8 that is not in ASCII:

preferences:
54.12 ms | 406 KiB | 5 Q