3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $person = new class($controller) { public $age = 15, $height = 72, $weight = 200; public function __set($name, $value) { if (!property_exists($this, $name)) { throw new Exception("No such property: $name"); } $this->{$name} = $value; } public function __get($name) { if (!property_exists($this, $name)) { throw new Exception("No such property: $name"); } return $this->{$name}; } }; var_dump($person); var_dump($person->age); $person->age = 19; var_dump($person->age); try { var_dump($person->badProp); } catch (Exception $e) { var_dump($e); } try { $person->badProp = 5; } catch (Exception $e) { var_dump($e); }
based on USatZ
Output for 7.2.0
Notice: Undefined variable: controller in /in/fb5IQ on line 3 object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f3e7d3671df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f3e7d3671df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.1.10
Notice: Undefined variable: controller in /in/fb5IQ on line 3 object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f523d9b31df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f523d9b31df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.1.7
Notice: Undefined variable: controller in /in/fb5IQ on line 3 object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f9fc34261df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f9fc34261df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.1.6
Notice: Undefined variable: controller in /in/fb5IQ on line 3 object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7fc4514191df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7fc4514191df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.1.5
Notice: Undefined variable: controller in /in/fb5IQ on line 3 object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f0eef4ec1df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f0eef4ec1df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.1.0
Notice: Undefined variable: controller in /in/fb5IQ on line 3 object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7fd5f93fa1df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7fd5f93fa1df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.0.20
object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7fea14df81df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7fea14df81df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.0.6
object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f89c1b2f1df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f89c1b2f1df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.0.5
object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f5bec7f11df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f5bec7f11df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.0.4
object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f735675b1df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f735675b1df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.0.3
object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f46b000d1df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f46b000d1df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.0.2
object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f52f69301df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f52f69301df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.0.1
object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f0ca14d61df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f0ca14d61df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 7.0.0
object(class@anonymous)#1 (3) { ["age"]=> int(15) ["height"]=> int(72) ["weight"]=> int(200) } int(15) int(19) object(Exception)#2 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(13) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(27) ["function"]=> string(5) "__get" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f7e0279f1df" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(7) "badProp" } } } ["previous":"Exception":private]=> NULL } object(Exception)#3 (7) { ["message":protected]=> string(25) "No such property: badProp" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/fb5IQ" ["line":protected]=> int(7) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(9) "/in/fb5IQ" ["line"]=> int(33) ["function"]=> string(5) "__set" ["class"]=> string(39) "class@anonymous/in/fb5IQ0x7f7e0279f1df" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(7) "badProp" [1]=> int(5) } } } ["previous":"Exception":private]=> NULL }
Output for 5.4.2 - 5.6.28
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/fb5IQ on line 3
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected T_CLASS in /in/fb5IQ on line 3
Process exited with code 255.