Blogger Information
Blog 10
fans 0
comment 1
visits 8254
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
抽象类
夏涛的博客
Original
737 people have browsed it

<?php 

abstract class Demo{

    public $name;

    public function __construct($name){

        $this->name=$name;

    }

    abstract public function hello();

    abstract public function say();

    public function test(){

        return 'Demo::test()';

    }

}

class Demo1 extends Demo{

    public function hello(){

        return 'hello,'.$this->name;

    }

    public function say(){

        return '我的name是:'.$this->name;

    }

}

$obj=new Demo1('php');

 echo $obj->hello();

 echo '<hr>';

 echo $obj->say();

 echo '<hr>';

 echo $obj->test();

 ?>



Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
  • 1970-01-01 08:00:00