10 minutes Learning php Face Object Basics (Ⅳ)

Source: Internet
Author: User

The son said: "Warm so know new, can for the teacher"

123 of the content, the directory is as follows:

Set up class person{...}

Instantiate class $p 1 = new person ();

Inheriting class children extend person{...}

In succession, it is said that you can increase your own properties and methods;

The methods of two methods are constructed by __construct and __destruct.

Private,protected,public these three levels of attributes, methods have been invoked by the restrictions;

The assignment of the private property can be realized by __construct;

On this basis, the __set ($name, $value) settings are provided, __get ($name) are obtained, and the __unset ($name) method of __isset ($name) and emptying attribute values is set;

Through the parent:: In a sense to implement overloading, for subclasses to add some of the parent class method does not exist in the function;

Final defines some classes or methods that can no longer be duplicated;

Static methods or properties, which define statically classes and properties that allow all inheritors to use the same static space, static methods can only invoke static properties in the class, static properties, methods to be called with the class Name:: Property/method;

Const defines constant const PI = "3.14"; also use class name::p I to use;

__tostring () {} If the direct echo $p 1 will be error, but in the __tostring set the return value, the output will output the set return value;

Clone and __clone () clones the instance, obtain an identical instance, can define some changes after the clone through __clone (), __clone () {$this->age = $this->age. " Hehe "};

__call () {$name, $array} When a method of a nonexistent class is called, if a predefined __call can bypass the error, continue execution, and obtain the non-existent method name and argument, the parameter is returned in an array;

10 minutes Learning php Face Object Basics (Ⅳ)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.