php深入学习笔记二( 函数内置函数 )
来源:互联网 发布:提高智商知乎 编辑:程序博客网 时间:2024/06/02 04:16
1. call_user_func_array
调用用户自定义函数,第一个参数是函数名,第二个参数是函数的参数 必须是是一索引数组
function foobar($arg, $arg2) { echo __FUNCTION__, " got $arg and $arg2\n";}class foo { function bar($arg, $arg2) { echo __METHOD__, " got $arg and $arg2\n"; }}// 普通函数调用call_user_func_array("foobar", array("one", "two"));// 类成员函数调用$foo = new foo;call_user_func_array(array($foo, "bar"), array("three", "four"));
2. call_user_func
调用函数 参数不能传递引用 参数call_user_func(函数名,参数1,参数2...)
call_user_func(function($arg) { print "[$arg]\n"; }, 'test');
3. create_function
创建一个匿名函数$myfunc = create_function('函数参数','函数体');
$myfunc(函数参数);
$newfunc = create_function('$a,$b', 'return "ln($a) + ln($b) = " . log($a * $b);');echo "New anonymous function: $newfunc\n";echo $newfunc(2, M_E) . "\n";
4. forward_static_call_array
调用一个静态函数 方式同 call_user_func_array5. forward_static_call
调用一个静态函数 方式同 call_user_func6. func_get_arg(index)
返回参数列表的某一项 参数为索引值7. func_get_args
以数组形式收集所有参数<?phpfunction sum() { $acc = 0; foreach (func_get_args() as $n) { $acc += $n; } return $acc;}echo sum(1, 2, 3, 4);?>
8. func_num_args()
返回函数传递参数的个数9. function_exists
检测函数是否存在
function_exists("函数名"); // 检测一个函数是否存在10. get_defined_functions
以二维数组形式返回所有定义过的函数包括系统函数 (internal)
和用户自定义函数(user)
Array( [internal] => Array ( [0] => zend_version [1] => func_num_args [2] => func_get_arg [3] => func_get_args [4] => strlen [5] => strcmp [6] => strncmp ... [750] => bcscale [751] => bccomp ) [user] => Array ( [0] => myrow ))
11. register_shutdown_function
该函数注册的函数 ,在系统执行超过最大时间Fatal error时仍会执行 注册的函数
function add(){ code here... } register_shutdown_function("add");
1 0
- php深入学习笔记二( 函数内置函数 )
- 我的php学习笔记(二十六)PHP模板引擎Smarty内置函数
- PHP学习笔记六之MySQL内置函数
- PHP学习笔记(二)函数
- python学习笔记(二)--深入了解python函数
- PHP模板学习--Smarty 内置函数
- 5.php内置MySQL函数学习
- PHP学习笔记-函数
- PHP函数学习笔记
- php学习笔记--函数
- MySQL学习笔记_7_MySQL常用内置函数
- Python学习笔记——内置函数
- python 学习笔记之内置函数
- MySQL学习笔记_7_MySQL常用内置函数
- [Python学习笔记][Python内置函数]
- python学习笔记2---内置函数
- PHP数组内置函数
- php内置函数
- objective-c和java
- Flex datagrid单元格合并
- 知识点扫盲
- 视频会议图像因为qp值造成的灰屏的bug处理过程
- 动态代理在mybatis接口式编程中的应用
- php深入学习笔记二( 函数内置函数 )
- stm32需要的手册
- RPDB-让PDB(Python调试工具)支持远程调试功能
- 向注册表中注册文件类型
- Android中触摸事件传递过程
- add groups 配置
- 如何快速去除黑眼圈
- 在Ubuntu中安装kali tools
- Hadoop中SSH免密码登陆设置