このステートメントの 2 番目のプロパティまたはメソッドにアクセスする方法
$this->test->hello();
私の中では、プロパティが__get()
何であるかを理解する方法しか理解できません。test
「hello」メソッド呼び出しもキャプチャできるようにしたいです。そしてそれを使っていくつかの動的なことをします。
要するに、私が入力すると
$this->test->hello()
echo
セグメントごとにしたい
echo $propert // test
echo $method //hello
問題は、私のテストが外部クラスから新しいクラス オブジェクトをインスタンス化するために使用されていることです。メソッドはクラス オブジェクトhello
に属します。test
私は私の中にメソッドをキャプチャしたい__get()
.
これどうやってするの?
編集:
public function __get($name)
{
if ($name == 'system' || $name == 'sys') {
$_class = 'System_Helper';
} else {
foreach (get_object_vars($this) as $_property => $_value) {
if ($name == $_property)
$_class = $name;
}
}
$classname = '\\System\\' . ucfirst($_class);
$this->$_class = new $classname();
//$rClass = new \ReflectionClass($this->$_class);
$rClass = get_class_methods($this->$_class);
foreach($rClass as $k => $v)
echo $v."\n";
//print_r($rClass);
return $this->$_class;