3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Tell PHP that we're using UTF-8 strings until the end of the script mb_internal_encoding('UTF-8'); // Tell PHP that we'll be outputting UTF-8 to the browser mb_http_output('UTF-8'); // Our UTF-8 test string $string = 'Êl síla erin lû e-govaned vîn.'; $decoded_stuff = utf8_encode("Müller"); var_dump($decoded_stuff); $string2 = utf8_encode($string); var_dump($string2 ); ?><!doctype html> <html> <head> <meta charset="UTF-8" /> <title>UTF-8 test page</title> </head> <body> <?php foreach($result as $row){ print($row->Body); // This should correctly output our transformed UTF-8 string to the browser } ?> </body> </html>
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Function utf8_encode() is deprecated in /in/TTthk on line 12 string(9) "Müller" Deprecated: Function utf8_encode() is deprecated in /in/TTthk on line 15 string(42) "Êl síla erin lû e-govaned vîn." <!doctype html> <html> <head> <meta charset="UTF-8" /> <title>UTF-8 test page</title> </head> <body> Warning: Undefined variable $result in /in/TTthk on line 26 Warning: foreach() argument must be of type array|object, null given in /in/TTthk on line 26 </body> </html>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
string(9) "Müller" string(42) "Êl síla erin lû e-govaned vîn." <!doctype html> <html> <head> <meta charset="UTF-8" /> <title>UTF-8 test page</title> </head> <body> Warning: Undefined variable $result in /in/TTthk on line 26 Warning: foreach() argument must be of type array|object, null given in /in/TTthk on line 26 </body> </html>
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
string(9) "Müller" string(42) "Êl síla erin lû e-govaned vîn." <!doctype html> <html> <head> <meta charset="UTF-8" /> <title>UTF-8 test page</title> </head> <body> Notice: Undefined variable: result in /in/TTthk on line 26 Warning: Invalid argument supplied for foreach() in /in/TTthk on line 26 </body> </html>
Output for 4.3.0 - 4.3.10, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 7.3.32 - 7.3.33
string(9) "Müller" string(42) "Êl síla erin lû e-govaned vîn." <!doctype html> <html> <head> <meta charset="UTF-8" /> <title>UTF-8 test page</title> </head> <body> Warning: Invalid argument supplied for foreach() in /in/TTthk on line 26 </body> </html>
Output for 4.3.11
string(9) "Müller" string(42) "Êl síla erin lû e-govaned vîn." <!doctype html> <html> <head> <meta charset="UTF-8" /> <title>UTF-8 test page</title> </head> <body> </body> </html>

preferences:
355.61 ms | 401 KiB | 459 Q