You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
344 B

<?php
class clsA{
public $a = 'hello';
private $b;
public function __get($name)
{
echo "获取{$name}失败,{$name}未定义".'<br>';
}
}
$obj = new clsA();
$obj -> a = 'world';
echo $obj -> b; //b未定义,当b被调用时,自动调用了__get,自动传入key
?>