您好,欢迎访问一九零五行业门户网

PHP反射类之妙用

//php reflection class is to create a instance of a class which name isspecified ?php class abc { private $p1; private $p2; function __construct($array) { $this-p1 = $array [0]; $this-p2 = $array [1]; } function getp1() { return $this-p1;
//php reflection class is to create a instance of a class which name is specified
p1 = $array [0];
  $this->p2 = $array [1];
 }
function getp1() {
  return $this->p1;
 }
function getp2() {
  return $this->p2;
 }
}
$arr = array (0 => 'p1', 1 => 'p2' );
$class = new reflectionclass ( 'abc' );
$aobj = $class->newinstance ( $arr );
echo $aobj->getp1 ();
echo $aobj->getp2 ();
?>
其它类似信息

推荐信息