public function index(){
import('Class.object_array',APP_PATH);// 导入分页类
$data = array('name' =>'魏巍' ,'age'=>15,'sex'=>'男','hobby'=>'喜欢起凡的网虫' );
$obj = object_array::get_object($data);
p($obj);
}
实现的效果:class TestAction extends CommonAction{
public function index(){
import('Class.object_array',APP_PATH);// 导入分页类
$hobby['pingpang']=new Hobby('乒乓球','2年');
$hobby['qifan']=new Hobby('起凡','6年');
$me=new Human('魏巍',15,'男',$hobby);
$array = object_array::get_array($me);
p($array);
}
}
/*
人类
*/
class Human {
public $name;
public $age;
public $sex;
public $hobby;
public function Human($name,$age,$sex,$hobby) {
$this->name = $name;
$this->age = $age;
$this->sex = $sex;
$this->hobby = $hobby;
}
}
/*
爱好类
*/
class Hobby{
public $name;
public $time;
public function Hobby($name,$time){
$this->name=$name;
$this->time=$time;
}
}
运行效果图:object_array.class.rar ( 365 B 下载:36 次 )