标签:func ati 笔试 style pre value php ret 1.0
//已经定义以下php类 class People{ static $version = "1.02beta"; private $age; public function m($key,$value=NULL){ if($value == NULL){ return $this->key; }else{ $this->key = $value; } } } //1、用echo输出People的版本号 echo People::$version; echo "<br/>"; //2、实例化一个People,叫$jack,并给他的age赋值为50 $jack = new People(); $jack->m("age",50); echo $jack->m("age");
/** * 继承People的子类Child,Child在实例化时,会自动echo父类的版本号。 */
/**People.class.php文件**/ class People{ static $version = "1.02beta"; private $age; public function m($key,$value=NULL){ if($value == NULL){ return $this->key; }else{ $this->key = $value; } } } /**Child.class.php文件**/ require "People.class.php"; class Child extends People{ public function __construct(){ echo parent::$version;//输出父类版本号 } } //输出父类版本号 new Child();
标签:func ati 笔试 style pre value php ret 1.0
原文地址:http://www.cnblogs.com/yxhblogs/p/6810499.html