3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 5.0.5 - 7.1.0
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 />