3v4l.org

run code in 300+ PHP versions simultaneously
<?php function var_import($var) { if (strcasecmp($var, 'null') === 0) { return null; } if (strcasecmp($var, 'true') === 0) { return true; } if (strcasecmp($var, 'false') === 0) { return false; } if ($var === ((string) (int) $var)) { return (int) $var; } if ($var === ((string) (float) $var)) { return (float) $var; } if (preg_match('<^"((?:[^"\\\\]|\\\\.)*)"|\'((?:[^\'\\\\]|\\\\.)*)\'$>', $str)) { return eval('return ' . $var . ';'); } throw new YUNOMAEKSENSEException('dumbass.'); } foreach ([ '1', '2.3', 'true', 'FALSE', 'Null', '"foo\nbar"', 'foobar', ] as $var) { ob_start(); var_dump(var_import($var)); echo sprintf('"%s" => %s', $var, trim(ob_get_clean())) . PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
"1" => int(1) "2.3" => float(2.3) "true" => bool(true) "FALSE" => bool(false) "Null" => NULL Warning: Undefined variable $str in /in/6iZRd on line 20 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/6iZRd on line 20 Fatal error: Uncaught Error: Class "YUNOMAEKSENSEException" not found in /in/6iZRd:23 Stack trace: #0 /in/6iZRd(36): var_import('"foo\\nbar"') #1 {main} thrown in /in/6iZRd on line 23
Process exited with code 255.

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:
37.45 ms | 402 KiB | 8 Q