首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

种与in_array

2012-12-26 
类与in_arraytest.php?phpclass test{private $nameprivate $pas dddprivate $name1 truefuncti

类与in_array
test.php
<?php

class test{

private $name;
private $pas = 'ddd';
private $name1 = true;

function __construct($array1=array()){

foreach ($array1 as $key=>$value){

if(!in_array($key,array_keys(get_class_vars(get_class($this))))){
continue;
}

$this->setOption($key,$value);
}

}

private function setOption($key,$value){
$this->$key = $value;
}


}

?>
index.php
<?php

require 'test.php';
$object = new test(array('name'=>'xuepeng11'));

var_dump($object);


?>

热点排行