实例
<?php //1、命名解决了相同名称冲突的问题,把类放到不同的命名空间里。 namespace mail; class send{ public $a = 123; }; namespace mobel; class send{ public $a = 123; }; //继承 class mobile{ private $brand = '华为'; private $modle = 'b3-22'; private $color = 'red'; private $width = 200; private $height = 500; public function main(){ return $this->brand.'手机:'.'型号:'.$this->modle.',颜色:'.$this->color.',宽:'.$this->width.'mm,'.'长度:'.$this->height.'mm'; } } class huawei extends mobile { } $obj = new huawei(); echo $obj->main();
运行实例 »
点击 "运行实例" 按钮查看在线实例