`
xuepengcheng
  • 浏览: 45376 次
  • 性别: Icon_minigender_1
  • 来自: 郴州
社区版块
存档分类
最新评论

类与in_array

    博客分类:
  • PHP
PHP 
阅读更多
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);


?>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics