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;

preferences:
25.67 ms | 406 KiB | 5 Q