Come to the conclusion today.
, when accessing properties declared as const and static in the inner method of a class, use Self:: $name form. Note that the Const attribute's declaration format, const PI=3.14, is not const $PI =3.14
Copy CodeThe code is as follows:
Class Clss_a {
private static $name = "Static Class_a";
Const pi=3.14;
Public $value;
public static function GetName ()
{
Return self:: $name;
}
This is incorrect, static methods cannot access non-static properties
public static function GetName2 ()
{
Return self:: $value;
}
Public Function GETPI ()
{
Return self::P i;
}
}
It is also important to note that if the method of the class is static, the property that he accesses must also be static.
, use $this->value = ' class_a ' When accessing properties that are not declared const and static in the inner method of the class.
http://www.bkjia.com/PHPjc/320765.html www.bkjia.com true http://www.bkjia.com/PHPjc/320765.html techarticle come to the conclusion today. , when accessing properties declared as const and static in the inner method of a class, use Self:: $name form. Note The Const attribute's declaration format, const pi=3.14, and ...