Sample code for simple implementation of PHP5 multi-inheritance

Source: Internet
Author: User
Simple implementation of multiple PHP5 inheritance. In the following code :? PHP5 interface --- a bird like JAVA ~ Dizzy interfaceIFOne {functiongetName ();} interfaceIFTwo {functiongetID ();} we can know through learning the PHP language that PHP4 cannot implement multiple inheritance. What about PHP5? We tested PHP5 and found that the implementation method of multiple inheritance of PHP5 is very simple.

Usage of PHP upload class upload. php

How to use PHP Ajax to implement refreshing image uploads

How to parse PHP5 destructor

Application of PHP5 magic functions

How to connect PHP mysqli to the MySQL database

The code for the multiple inheritance of PHP5 is as follows:

 Name = $ name ;}} abstract class AbsClsTwo {var $ id; function setID ($ id) {$ this-> id = $ id ;}} // class ExtendsMoreCls extends AbsClsOne implements IFOne, IFTwo {var $ id; private static $ priVar = "private"; function construct () {// PHP5 constructor self: $ priVar = "set private"; $ this-> id = 0;} function destruct () {// interpretation function echo "ExtendsMoreCls destruct";} function getName () {return $ this-> name;} function getID () {return $ this-> id ;} public static function clsStaticFunc () {echo "static function" ;}}$ emc = new ExtendsMoreCls (); $ emc-> setName ("kj021320 "); echo $ emc-> getName (); echo"
"; Echo $ emc-> getID (); echo"
"; ExtendsMoreCls: clsStaticFunc (); // call the static method echo"
";?>

The output structure is

kj0213200static functionExtendsMoreCls destruct

The above is the sample code for simple implementation of PHP5 multi-inheritance. For more information, see PHP Chinese network (www.php1.cn )!

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.