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 )!