A lot of object-oriented ideas have been added to PHP5. The object-oriented ideas of PHP5 are closer to the object-oriented ideas of Java. Here we will describe the functions of static and const keywords in PHP5, hoping to be helpful to friends who are learning PHP5.
(1) static
The static keyword in a class is used to describe a member as static. static can restrict external access, because the members after static belong to the class and do not belong to any object instance. Others The class is inaccessible and is only shared by instances of the class. A certain program must protect the members. Static variables of a class are very similar to global variables and can be shared by all instances of the class. The same is true for static methods of a class, similar to global functions. Static methods of a class can access static properties of the class. In addition, static members must be accessed using self. Using this will cause an error.
(For the similarities and differences between this and self, please refer to: http://blog.csdn.net/heiyeshuwu/archive/2004/11/03/165828.aspx )
(2)const
const is A keyword defining a constant, similar to #define in C, can define a constant. If its value is changed in the program, an error will occur.
Example the above code: (Note: The following code is from phpe.net)