<?php
class A {
protected $a = 2;
}
class B extends A {
//private $a;
protected $a = 3;
public function square() {
echo $this->a * parent::$a();
}
}
$obj = new B();
$obj->square ();
Warning: Undefined variable $a in /in/c5pEj on line 10
Fatal error: Uncaught Error: Method name must be a string in /in/c5pEj:10
Stack trace:
#0 /in/c5pEj(15): B->square()
#1 {main}
thrown in /in/c5pEj on line 10
Process exited with code 255.
Notice: Undefined variable: a in /in/c5pEj on line 10
Fatal error: Uncaught Error: Function name must be a string in /in/c5pEj:10
Stack trace:
#0 /in/c5pEj(15): B->square()
#1 {main}
thrown in /in/c5pEj on line 10
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26
Fatal error: Uncaught Error: Function name must be a string in /in/c5pEj:10
Stack trace:
#0 /in/c5pEj(15): B->square()
#1 {main}
thrown in /in/c5pEj on line 10
Process exited with code 255.
Notice: Undefined variable: a in /in/c5pEj on line 10
Fatal error: Function name must be a string in /in/c5pEj on line 10
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: a in /in/c5pEj on line 10
Fatal error: Function name must be a string in /in/c5pEj on line 10
Process exited with code 255.
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/c5pEj 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/c5pEj 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/c5pEj on line 4
Process exited with code 255.