3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); $string = <<<'EOF' Bar <meta content="text/html; charset=unicode" http-equiv="Content-Type"> Foo EOF; libxml_use_internal_errors(true); $dom = new DOMDocument(); $dom->loadHTML($string); $f = $dom->saveHTML(); echo $f . PHP_EOL . PHP_EOL; $weirdStuff = preg_match('/>([\&\#a-zA-Z0-9\;]+)</', $f, $result); echo $result[1] . PHP_EOL . PHP_EOL; $utf8 = mb_convert_encoding($result[1], 'UTF-8', 'HTML-ENTITIES'); echo $utf8 . PHP_EOL . PHP_EOL; echo iconv('UTF-8', 'unicode', $utf8) . PHP_EOL . PHP_EOL;
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><p>Bar <meta content="text/html; charset=unicode" http-equiv="Content-Type">&#15882;&dagger;&#8262;&#28527;</p></body></html> &#15882;&dagger;&#8262;&#28527; 㸊†⁆潯 Warning: iconv(): Wrong encoding, conversion from "UTF-8" to "unicode" is not allowed in /in/kJ0tV on line 22
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.4.33
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><p>Bar <meta content="text/html; charset=unicode" http-equiv="Content-Type">&#15882;&dagger;&#8262;&#28527;</p></body></html> &#15882;&dagger;&#8262;&#28527; 㸊†⁆潯 Fatal error: Uncaught Error: Call to undefined function iconv() in /in/kJ0tV:22 Stack trace: #0 {main} thrown in /in/kJ0tV on line 22
Process exited with code 255.
Output for 7.4.0 - 7.4.32
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><p>Bar <meta content="text/html; charset=unicode" http-equiv="Content-Type">&#15882;&dagger;&#8262;&#28527;</p></body></html> &#15882;&dagger;&#8262;&#28527; 㸊†⁆潯 Notice: iconv(): Wrong charset, conversion from `UTF-8' to `unicode' is not allowed in /in/kJ0tV on line 22

preferences:
149.89 ms | 411 KiB | 5 Q