<?php
//类常量
class BaseClass{
const NAME="欧阳冬";
const AGE=30;
const ADDRESS="湖北省襄阳市";
static function action(){
return array(
"姓名"=>self::NAME,
"年龄"=>self::AGE,
"地址"=>self::ADDRESS,
);
}
}
?>
<?php
//继承于BaseClass
class sonClass extends BaseClass{
function result(){
return parent::action();
}
}
?>
<?php
//调用
$class=new sonClass();
var_dump($class->result());
?>
输出:
array (size=3)
'姓名' =>
string
'欧阳冬' (length=6) '年龄' =>
int
30
'地址' =>
string
'湖北省襄阳市' (length=12)