Let’s summarize today.
. When the internal method of a class accesses attributes that have been declared as const and static, use the form of self::$name. Note that the declaration format of the const attribute is const PI=3.14, not const $PI=3.14
Copy the code The 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 way of writing is wrong, static methods cannot access non-static properties
public static function getName2 ()
{
return self::$value;
}
public function getPI()
{
return self::PI;
}
}
The above introduces the use of cgiqqzonestatic php self,$this,const,static,->, including the content of cgiqqzonestatic. I hope it will be helpful to friends who are interested in PHP tutorials.