PHP Development (18)-include-closure-anonymous-PhpStorm

Source: Internet
Author: User
* 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 )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.