Come to the conclusion today.
, when the internal method of a class accesses a property that has been declared as const and static, use the self:: $name form. Note The Const attribute's declaration format, const pi=3.14, not const $PI =3.14
Copy Code code 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, and 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 properties that he accesses must also be static.
, when the internal method of the class accesses an attribute that is not declared const and static, use the form of $this->value = ' class_a ';