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)); var_export(new Foo(true)); var_export(new Foo(10)); var_export(new Foo('text string')); var_export(new Foo(array(1,2,3)));

preferences:
29.97 ms | 402 KiB | 5 Q