<?php
//普通函数
function f1($arg1,$arg2)
{
echo __FUNCTION__.'exec,the args is:'.$arg1.' '.$arg2;
echo "<br/>";
}
//通过call_user_func调用函数f1
call_user_func('f1','han','wen');
//通过call_user_func_array调用函数
call_user_func_array('f1',array('han','wen'));
class A
{
public $name;
function show($arg1)
{
echo 'the arg is:'.$arg1."<br/>";
echo 'my name is:'.$this->name;
echo "<br/>";
}
function show1($arg1,$arg2)
{
echo __METHOD__.' exec,the args is:'.$arg1.' '.$arg2."<br/>";
}
public static function show2($arg1,$arg2)
{
echo __METHOD__.' of class A exec, the args is:'.$arg1.' '.$arg2."<br/>";
}
}
//调用类中非静态成员函数,该成员函数中有$this调用了对象中的成员
$a = new A;
$a->name = 'wen';
call_user_func_array(array($a,'show',),array('han!'));
//调用类中非静态成员函数,没有对象被创建,该成员函数中不能有$this
call_user_func_array(array('A','show1',),array('han!','wen'));
//调用类中静态成员函数
call_user_func_array(array('A','show2'),array('argument1','argument2'));
f1exec,the args is:han wen f1exec,the args is:han wen the arg is:han! my name is:wen A::show1 exec,the args is:han! wen A::show2 of class A exec, the args is:argument1 argument2
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有