<?php

class Person
{
    public $name;
    public $sex;
    public function __construct($name,$sex=1)
    {
        $this->name = $name;
        $this->sex = $sex;
    }

    public function getName()
    {
        return $this->name;
    }
}

$reflect = new ReflectionClass('Person');
$constructor = $reflect->getConstructor ();
$res = $reflect->newInstanceArgs(['name'=>'wang']) ;

var_dump($res->getName());

?>

  

相关文章:

  • 2021-06-28
  • 2022-03-01
  • 2021-05-21
  • 2022-12-23
  • 2021-07-11
  • 2021-10-29
  • 2022-02-13
猜你喜欢
  • 2022-01-20
  • 2021-06-14
  • 2021-11-28
  • 2021-10-16
  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
相关资源
相似解决方案