3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tags = array("start" => "[highlight]", "finish" => "[/highlight]"); $text = 'Some normal text. [highlight]<?php echo $somedata; ?>[/highlight] Some normal text.'; $start = strpos($text,$tags['start']); $finish = strpos($text,$tags['finish']); $code = substr($text,$start+strlen($tags['start']),($finish-($start+strlen($tags['start'])))); $highlighted = highlight_string($code,true); $text = str_replace($code,"¬",$text); $text = str_replace("¬",$highlighted,$text); $text = str_replace($tags['start'],"",$text); $text = str_replace($tags['finish'],"",$text); echo $text.'<br />';
Output for 8.3.0 - 8.3.6
Some normal text. <pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php </span><span style="color: #007700">echo </span><span style="color: #0000BB">$somedata</span><span style="color: #007700">; </span><span style="color: #0000BB">?&gt;</span></code></pre> Some normal text.<br />
Output for 5.0.5, 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.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Some normal text. <code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$somedata</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">?&gt;</span> </span> </code> Some normal text.<br />
Output for 5.0.0 - 5.0.4
Some normal text. <code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php </span><span style="color: #007700">echo </span><span style="color: #0000BB">$somedata</span><span style="color: #007700">; </span><span style="color: #0000BB">?&gt;</span> </span> </code> Some normal text.<br />
Output for 4.4.0 - 4.4.9
Some normal text. <code><font color="#000000"> <font color="#0000BB">&lt;?php&nbsp;</font><font color="#007700">echo&nbsp;</font><font color="#0000BB">$somedata</font><font color="#007700">;&nbsp;</font><font color="#0000BB">?&gt;</font> </font> </code> Some normal text.<br />
Output for 4.3.0 - 4.3.11
Some normal text. <code><font color="#000000"> <font color="#0000BB">&lt;?php </font><font color="#007700">echo </font><font color="#0000BB">$somedata</font><font color="#007700">; </font><font color="#0000BB">?&gt;</font> </font> </code> Some normal text.<br />

preferences:
221.38 ms | 402 KiB | 341 Q