Subclasses use parent class variables
Class A {
var $authKey = ' 1111 ';
}
Class B extends a{
__construct () {
Echo Parent::authkey;
}
}
Error undefined class constant ' AuthKey '
------Solution--------------------
The error message means a constant that is undefined. You're missing a $.
But $authkey is not a static variable, so you can't call it so statically
The right approach
PHP code
class A {//Do not recommend using VAR in class to declare the variable public $authKey = ' 1111 ';} Class B extends a{//b will have all non-private members of a public function __construct () {echo $this->authkey; }}
------solution--------------------
Var was in the previous version of PhP4 and was later omitted.
------Solution--------------------
var is best taken with the case! Some of the lower versions support
------Solutions--------------------
var is php 4.X,, 5+ used in order to backward compatibility,
New program, basically can give up this type of writing
Your code can also use
PHP code
class A {const authkey= ' 1111 ';} Class B extends a{public function __construct () {echo parent::authkey;}} New B;