3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = 1; $b = 2; $content = <<<BLOCK <h1>Some Html</h1> <hr> {IF:($a + $b === 3)} <b>Yes :)</b> {ELSE} <b>No :(</b> {ENDIF} Another one... {IF:($a + $b === 4)} <b>:)</b> {ELSE} <b>:(</b> {ENDIF} Some more Text BLOCK; echo render($content); function render($content) { $match = preg_match_all('/{IF:\((.*?)\)}(.*?){ELSE}(.*?)({ENDIF})/s', $content, $matches, PREG_OFFSET_CAPTURE); if (!$match) { return $content; } $beforeIf = substr($content, 0, $matches[0][0][1]); $afterIf = substr($content, $matches[4][0][1] + strlen('{ENDIF}')); $evalCondition = eval('return (' . $matches[1][0][0] . ');'); if ($evalCondition) { $ifResult = $matches[2][0][0]; } else { $ifResult = $matches[3][0][0]; } return $beforeIf . $ifResult . render($afterIf); }
Output for git.master, git.master_jit, rfc.property-hooks
<h1>Some Html</h1> <hr> <b>Yes :)</b> Another one... <b>:(</b> Some more Text

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
29.34 ms | 405 KiB | 5 Q