closurez在php中的使用方法有哪些-创新互联
这期内容当中小编将会给大家带来有关closurez在php中的使用方法有哪些,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
Closure,匿名函数,是php5.3的时候引入的,又称为Anonymous functions。字面意思也就是没有定义名字的函数。比如以下代码(文件名是do.php)
<?php function A() { return 100; }; function B(Closure $callback) { return $callback(); } $a = B(A()); print_r($a);//输出:Fatal error: Uncaught TypeError: Argument 1 passed to B() must be an instance of Closure, integer given, called in D:\web\test\do.php on line 11 and defined in D:\web\test\do.php:6 Stack trace: #0 D:\web\test\do.php(11): B(100) #1 {main} thrown in D:\web\test\do.php on line 6 ?>
当前文章:closurez在php中的使用方法有哪些-创新互联
当前链接:http://tyjierui.cn/article/ddsgsh.html