Use of phpself, $ this, const, static,-& amp; gt. Summary. When the internal method of the class accesses the attributes declared as const and static, use the form of self ::$ name. Note that the declarative format of the const attribute is constPI3.14, which is summarized today.
When the internal method of the class accesses the attributes declared as const and static, use the form of self ::$ name. Note the declarative format of the const attribute. const PI = 3.14 instead of const $ PI = 3.14.
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 statement is incorrect. the static method cannot access non-static attributes.
Public static function getName2 ()
{
Return self: $ value;
}
Public function getPI ()
{
Return self: PI;
}
}
Note that if the class method is static, the Accessed attribute must also be static.
When the internal method access of the class is not declared as const or static, use the form of $ this-> value = 'class _.
Bytes. When the internal method of the class accesses the attributes declared as const and static, use the form of self ::$ name. Note that the declarative format of the const attribute, const PI = 3.14, and...