* An anonymous function (Anonymousfunctions) is also called a closure function (closures). a function with no specified name can be created temporarily. PHP Development (18)-include-closure-anonymous-PhpStorm
* An Anonymous function (Anonymous functions), also called a closure function (closures), allows temporary creation of a function without a specified name.
* It is most often used as the value of the callback function parameter. Of course, there are other applications.
* Http://php.net/manual/zh/functions.anonymous.php
* The include (or require) statement obtains all the text, code, and tags in the specified file and copies them to the file using the include statement.
* File inclusion is useful if you need to reference the same PHP, HTML, or text on multiple pages of the website.
* Http://www.w3school.com.cn/php/php_includes.asp
Today's exercise contains four files. please refer to the following code: (no texture, the print result written by index. php is the actual result ~)
Index. php:
"; Echo $ jianfa (); // Here we call an included closure function. print the result: 11 echo"
"; Function callFunc ($ x) {// An anonymous function is called here. print the result: Anonymous function $ x (" anonymous function ");}; callFunc (function ($ str) {echo $ str ;});
Function. inc. php:
";} Function two () {echo" 222
";} Function three () {echo" 333
";} Function add ($ a, $ B, $ c) {return $ a + $ B + $ c ;} /*** new features of the closure function php5.4 but not commonly used. we generally use the following anonymous function syntax * generally used for function callback */$ jianfa = function ($ a, $ B) {return $ a-$ B;};/*** anonymous function * // callFunc (function ($ str) {// echo $ str ;//});
Test.html:
testtesttesttesttesttesttesttesttesttest
Ceshi.txt:
ceshiceshiceshiceshiceshiceshi
The above is the content of PHP Development (18)-include-closure-anonymous-PhpStorm. For more information, see The PHP Chinese website (www.php1.cn )!