Simple implementation of PHP5 multiple inheritance sample code

Source: Internet
Author: User
Tags php language
In the study of PHP language, we can know that PHP4 is unable to achieve multiple inheritance. So what about PHP5? We conducted a test on PHP5 and found that the implementation of PHP5 multiple inheritance was very simple.

How to use PHP upload class upload.php

How to use PHP Ajax to implement a non-flush upload of images

The concrete use method of analytic PHP5 destructor

The specific application of PHP5 magic function

PHP mysqli How to connect to MySQL database

The following is the specific code for PHP5 multiple inheritance:

<?  PHP5 interface---and java a bird-like ~ Halo interface ifone{function GetName ();  } Interface iftwo{function GetID ();   }//php abstract class absclsone{var $name;   function SetName ($name) {$this->name= $name;   }} abstract class absclstwo{var $id;   function SetID ($id) {$this->id= $id;   }}//single-Inheritance multi-implementation 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 () {//Release 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 "<br>";  echo $EMC->getid ();  echo "<br>";  Extendsmorecls::clsstaticfunc ();//Call static method echo "<br>"; ?>

The structure of the output is

Kj0213200static Functionextendsmorecls Destruct

The above is the simple implementation of PHP5 multiple inheritance of the content of the sample code, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • Related Article

    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.