3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class testo{ public $val='oo'; public function __construct(){ $this->val = $val; } } // your code goes here $t = new testo(); $a=$t->val='ok'; echo $a ; $tt = new testo('ooooh'); echo $tt ;
Output for 7.1.0
Notice: Undefined variable: val in /in/Nsm1P on line 9 ok Notice: Undefined variable: val in /in/Nsm1P on line 9 Recoverable fatal error: Object of class testo could not be converted to string in /in/Nsm1P on line 23
Process exited with code 255.
Output for 5.2.0 - 5.6.25, hhvm-3.10.0, 7.0.0 - 7.0.14
Notice: Undefined variable: val in /in/Nsm1P on line 9 ok Notice: Undefined variable: val in /in/Nsm1P on line 9 Catchable fatal error: Object of class testo could not be converted to string in /in/Nsm1P on line 23
Process exited with code 255.
Output for hhvm-3.12.0
Notice: Undefined variable: val in /in/Nsm1P on line 9 ok Notice: Undefined variable: val in /in/Nsm1P on line 9 Fatal error: Uncaught Error: Object of class testo could not be converted to string in /in/Nsm1P:23 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.0.4 - 5.1.6
Notice: Undefined variable: val in /in/Nsm1P on line 9 ok Notice: Undefined variable: val in /in/Nsm1P on line 9 Object id #2
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: val in /in/Nsm1P on line 9 ok Notice: Undefined variable: val in /in/Nsm1P on line 9 Object id #2
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Nsm1P on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Nsm1P on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/Nsm1P on line 4
Process exited with code 255.