New features of classes (class) in PHP5

Source: Internet
Author: User
Tags abstract inheritance



New features of classes (class) in PHP5

/******************************/
Author: older Youth
E_mail:wenadmin@sina.com
/*****************************/

PhP5 added a lot of new functions and features, but in the latest CHM manuals are not reflected in the online manual to find, annoying Ah!!!



No more nonsense, to see php5 in the new class contrast PHP2 class has what the characteristics.



1/Plus access control: using private/public/protected features



2/Added the concept of interface and abstract class, interface/abstract, unfortunately is the inheritance of the class or tree-like single inheritance.



3/Can define final function, cannot override this function in parent class



4/finally can be defined in the class static variables, in PHP can only be defined in the function,



static $AA = nulll;

The Const method is also provided

Const Mystatic = ' aaaaaa ';



5/New provides a self internal method

Echo self::mystatic;



6/Added the following internal features

__construct () initialization

__destruct (); Unloading

__get (); The organization returns some of the variable values in the class.

__set (); The organization assigns values to certain variable values in the class.

__call (); When you call a function of a nonexistent class, you have to deal with the method

__clone (); Copy object with

__sleep (); When serializing, use the

__weekup (); When the reverse sequence is used



7/The Default object assignment takes the form of an application, such as:

$object 2 = $object 1

$object 2 Gets a $object1 reference, not a copy in memory



8/ Provides the reflection API, which is used primarily to display the structure and statistics of the Class/function Province, a brand new thing that is hard to say, (though very powerful, but I still haven't found "where the hero can use")



9/provides an enumeration function for class objects that can be used to handle global variables in an object with a for loop.



10/provides a __autoload () function, used to automatically load class declaration file



Detailed information: http://www.php.net/manual/en/language.oop5.basic.php

</

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.