PHP5 provides 3 access methods:
Related recommendations: "php Basic Tutorial"
They are as follows:
(1) public: can be accessed without restrictions. Any code outside the class can read and write public properties. In versions before PHP5, all methods and Properties are all public.
(2) private: only visible inside the class. Any member and class instance in the class can access private members. Outside the class, the value of the private attribute cannot be changed or read, nor can Call private methods. Subclasses cannot access private members of the parent class.
(3) protected: Can be accessed by methods of the same class and inherited classes.
If not specified, the default is public.
The above is the detailed content of How to write php permission control. For more information, please follow other related articles on the PHP Chinese website!