批改状态:合格
老师批语:
<meta charset="UTF-8">
<?php
//方法重载 __call(),__callstatic()
class Test
{
public function __call($method,$arguments)
{
$args = implode(',',$arguments);
return '方法名:' .$method. '<br>参数' .$args;
}
public function select()
{
return __METHOO__;
}
}
$test = new Test();
echo $test->show(),'<hr>';
echo $test->show('上海','北京','深圳'),'<hr>';<?php
/**
* call_user_func_array() 执行方法回调
*/
echo call_user_func_array(function($m,$n){return $m+$n;},[10,20]),'<br>';
class Hello
{
public function add($m,$n)
{
return $m+$n;
}
}
echo call_user_func_array([(new Hello()),'add'],[40,50]);
class Hello1
{
public static function add($m,$n)
{
return $m+$n;
}
}
echo call_user_func_array(['Hello1','add'],[50,50]);点击 "运行实例" 按钮查看在线实例
点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号