3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = <<<'HTML' <p>mon texte de début</p> <pre> <?php # Pour afficher un tableau PHP $var['website'] = 'domain.tld'; $var['weblink'] = 'http://www.domain.tld'; # BUG ICI echo '<pre>'.print_r($var,1).'</pre>' echo 'My domain : '.$var['website'] ?> </pre> <p>mon texte de fin.</p> HTML; libxml_use_internal_errors(true); $dom = new DOMDocument; $dom->loadHTML('<html><head><meta charset="UTF-8"/></head><body>' . $text . '</body></html>'); foreach($dom->getElementsByTagName('body')->item(0)->childNodes as $childNode) { echo $dom->saveHTML($childNode); }
Output for 8.1.11 - 8.1.33, 8.2.10 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
<p>mon texte de début</p> <pre> <?php # Pour afficher un tableau PHP $var['website'] = 'domain.tld'; $var['weblink'] = 'http://www.domain.tld'; # BUG ICI echo '<pre>'.print_r($var,1).'</pre>' echo 'My domain : '.$var['website'] ?&gt; <p>mon texte de fin.</p>

preferences:
69.2 ms | 407 KiB | 5 Q