3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<EOD <h1>Escape HTML or Other Programming tags</h1> <p>This must be rendered without any problem</p> <p> <code style="display:block;background:rgb(230,230,230);padding:2%"> <h4>Show this title in HTML</h4> <p>This paragraph must be in <strong>HTML</strong> and this <a href="">Link</a> too !</p> <?php echo "Display this PHP code!"; ?> <script> alert("Don't pop-up please!"); </script> </code> <a href="">Link rendered</a> </p> EOD; $dom = new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); $preformattedCodeNode = $dom->createElement('pre'); foreach ($xpath->query("//code") as $codeNode) { $codeContent = ''; foreach($codeNode->childNodes as $codeChild) { $codeContent .= $dom->saveHTML($codeChild); } $preformattedCodeNode->textContent = $codeContent; $preformattedCodeNode->setAttribute('style', $codeNode->getAttribute('style')); $codeNode->parentNode->replaceChild($preformattedCodeNode, $codeNode); } $texte = $dom->saveHTML(); echo $texte;

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
150.57 ms | 2141 KiB | 8 Q