Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
// __get()
class user
{
private array $data =[
'age' => 18,
];
public function __get($name)
{
$a = array_key_exists($name, $this->data);
return $a ? $this->data[$name] : "$name 属性不存在" . '<br>';
}
// set()
public function __set ($name,$value) {
$this->$name = $value;
}
// __call()
public function __call($name, $age)
{
printf('%s , %s', $name, $age);
}
// __callstatic
public static function __callstatic($name, $age)
{
printf('%s, %s', $name, $age);
}
}
class stu
{
protected string $name;
private $age = 18;
// __construct()
public function __construct($name)
{
$this -> name =$name;
}
}
namespace one;
class a
{
public static function a1()
{
return __METHOD__;
}
}
echo a::a1() . '<br>';
echo two\a::a1() . '<br>';
echo \one\two\a::a1() . '<br>';
use \one\two\three\a as UserIndex;
echo a::a1() . '<br>';
namespace one\two;
class a
{
public static function a1()
{
return __METHOD__;
}
}