3v4l.org

run code in 300+ PHP versions simultaneously
<?php function evalJS($code) { $matches = []; preg_match_all('#var (.*)( |=|;)#', $code, $matches); foreach($matches[1] as $val) { $code = preg_replace('#'.$val.'#', '\$'.$val, $code); $code = preg_replace('#var \$'.$val.'#', '\$'.$val, $code); $code = preg_replace('#\$'.$val.'\.#', '\$'.$val.'->', $code); } $code = preg_replace('#\.#', '::', $code); $code = preg_replace('#(\'|")\+#', '$1.', $code); $code = preg_replace('#\+(\'|")#', '.$1', $code); echo($code); var_dump($matches); } class document { public function print($arg) { echo($arg); } } $js = <<<JS var foo = 'Hello '+'World!'; document.print(foo); JS; evalJS($js);
Output for git.master, git.master_jit, rfc.property-hooks
var foo = 'Hello '.'World!'; document::print(foo);array(3) { [0]=> array(1) { [0]=> string(28) "var foo = 'Hello '+'World!';" } [1]=> array(1) { [0]=> string(23) "foo = 'Hello '+'World!'" } [2]=> array(1) { [0]=> string(1) ";" } }

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:
43.59 ms | 401 KiB | 8 Q