PHP class and object. PHP classes and objects have completely rewritten the object model since PHP5 for better performance and more features. This is the biggest change since PHP4. PHP5 has a complete object model. PHP class and object
Since PHP 5, the object model has been completely rewritten to get better performance and more features. This is the biggest change since PHP 4. PHP 5 has a complete object model.
New features in PHP 5 include access control, abstract classes and final classes and methods, additional magic methods, interfaces, object replication, and type constraints.
PHP treats objects in the same way as references and handles, that is, each variable holds an object reference, rather than copying the entire object.
Attribute:
The variable member of a class is called an attribute.
The attribute declaration keyword can be public protected private.
The variables in the attribute can be initialized, but the initial value must be a constant, not a formula.
For example
Private $ name = "tom"; // OK
Private $ name = "tom". "jack"; // error
Constants in the class:
The constant value must be a fixed value, not a variable, class attribute, mathematical operator, function call, etc.
Only const NAME = 'Tom 'can be used to define constants.
The access constant adopts the class: NAME outside self: NAME.
Automatic loading class:
Case column:
Index. php file
GetName (); Name. php file
Since PHP 5, ghost has completely rewritten the object model to get better performance and more features. This is the biggest change since PHP 4. PHP 5 has a complete object model. PHP 5...