3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public bool $bool = false; public int $int = 0; public string $string = ''; public array $arry = []; public stdClass $obj; public function __construct($value) { try { $this->bool = $value; } catch (TypeError $e) {} try { $this->int = $value; } catch (TypeError $e) {} try { $this->string = $value; } catch (TypeError $e) {} try { $this->arry = $value; } catch (TypeError $e) {} try { $this->obj = $value; } catch (TypeError $e) {} } } var_export(new Foo(null)); echo PHP_EOL; var_export(new Foo(true)); echo PHP_EOL; var_export(new Foo(10)); echo PHP_EOL; var_export(new Foo('text string')); echo PHP_EOL; var_export(new Foo(array(1,2,3))); echo PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
\Foo::__set_state(array( 'bool' => false, 'int' => 0, 'string' => '', 'arry' => array ( ), )) \Foo::__set_state(array( 'bool' => true, 'int' => 1, 'string' => '1', 'arry' => array ( ), )) \Foo::__set_state(array( 'bool' => true, 'int' => 10, 'string' => '10', 'arry' => array ( ), )) \Foo::__set_state(array( 'bool' => true, 'int' => 0, 'string' => 'text string', 'arry' => array ( ), )) \Foo::__set_state(array( 'bool' => false, 'int' => 0, 'string' => '', 'arry' => array ( 0 => 1, 1 => 2, 2 => 3, ), ))

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