Home  >  Article  >  Backend Development  >  php5 download PHP5 object-oriented (learning record)

php5 download PHP5 object-oriented (learning record)

WBOY
WBOYOriginal
2016-07-29 08:41:20953browse

1. Inherit extends and can only inherit
public protected private attributes
__construct()
__destruct()
__get() to read private members
__set($n,$v) to set private members
2. Access parent class functions:: (also called scope character in C++)
7
3. Overload the function with the same name as the parent class
4. The abstract class abstract must be inherited and cannot be instantiated and the abstract function must be overridden. As long as one function in the class is static Then the class must be static
5. Common keywords
1. final When defining a class, the class cannot be inherited. When defining a function, the function cannot be overloaded
2. Self is used to access properties or methods in uninstantiated classes (static or Constant) Use the method self::property
3, static defines a static member or method that will only appear once in memory (non-static content cannot appear in a static method)
4, const defines a constant that can only modify member properties. Constants modified by properties do not add $.
6. Interface application interface interface definition keyword implements reference
Interface: all abstract methods, no need to add abstract attributes should be constants
interface Demo{}
class T implements Demo{} can reference multiple interfaces
Inherit first and then interface class a extends root implements Demo{}
Interface inherits interface interface D extends Demo
7, polymorphic PHP is a weakly typed language, so the support is not perfect
instanceof tests whether an instance comes from a class example: a{} $c = new a ; if($c instanceof a)
8, when the object is passed to the function as a parameter, the constructor is not run and it is not a copy, but the object address is passed
9, the object description configuration __tostring(){content} echoes the object directly
10. Object exception handling __call($name,$value) automatically absorbs your error when calling a non-existent method name and displays the value of $name and error parameters
11. Object cloning __clone() puts the clone key in the class Word (equivalent to the copy function of c++)
12, automatic loading function __autoload($class_n){
include($class_n.'php');
} Automatically load inlcude() a class when creating a new class by yourself

The above introduces the php5 download PHP5 object-oriented (learning record), including the content of php5 download. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn