<?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 ;
Warning: Undefined variable $val in /in/Nsm1P on line 9
ok
Warning: 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}
thrown in /in/Nsm1P on line 23
Process exited with code 255.
Output for 7.4.0 - 7.4.33
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}
thrown in /in/Nsm1P on line 23
Process exited with code 255.
Output for 7.3.32 - 7.3.33
ok
Recoverable fatal error: Object of class testo could not be converted to string in /in/Nsm1P on line 23
Process exited with code 255.
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.
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 5.0.4 - 5.0.5, 5.1.0 - 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.
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.