This article mainly introduces the class modifier of PHP and access modifiers, has a certain reference value, now share to everyone, the need for friends can refer to
class modifier
1.abstract decorated class is abstract class, if a class
There are three types of access modifiers in PHP , namely:Public (common, default)Protected (Protected)Private (privately)They can be used, respectively, on the properties and methods of a class (the properties and methods of a class are
There are three types of access modifiers in PHP, respectively:
Public (common, default)
Protected (Protected)
Private (privately)
Public (common, default) in PHP5 if the class does not have an access modifier for the specified member, the
There are three types of access modifiers in PHP, respectively:
public (common, default)
protected (Protected)
Private (private)
They can be used to modify the access rights of class members, respectively, on the properties and methods of
They can be used in the class attributes and methods (class attributes and methods are collectively called class members) to modify the access permissions of class members. PHP has three access modifiers:
Public (public, default)
Protected
There are three types of access modifiers in PHP, respectively:Public (common, default)Protected (Protected)Private (privately)Public (common, default) in PHP5 if the class does not have an access modifier for the specified member, the default is
Access modifiers in php oop
/*
The following two methods declare that the access permission works the same
*/
Function say (){};
Publilc function say (){};
When a class member is
Public, protected, privateUsed to describe:Member, which locations in the source code are accessible.Public: In the class, outside the class, within the inheritance chain classProtected: Within the class, within the inheritance chain class.Private:
The access modifiers of the type allow developers to restrict access to class members, which is a new feature of PHP5
Private
Protected
Public
In the same class
√
√
√
Class in the subclass
1.mysql Package ClassDefine parameters for initializing database connections in a constructor "because the parameter passed in when instantiating an object is the only parameter entry for that object"But instead of redundant definitions in the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.