Php study NOTE _ function type

Source: Internet
Author: User
: This article mainly introduces the php study notes function type. For more information about PHP tutorials, see. Differences between transferring variables to references
For example:

$ Num = 0; functiontest0 ($ num) {// Copy the value of the variable, instead of the variable itself. $ Num = 123; echo $ num;} test0 ($ num); // output: 123 echo $ num; // output: 0 $ num2 = 100; functiontest1 (& $ val) {// transmits the variable address to operate on the variable itself $ val = 300; echo $ val ;}test1 ($ num2); // output: 300 echo $ num2; // output: 300

Variable function, that is, the function name is a variable

$ Temp = "king"; $ name = "md5"; echo $ name ($ temp); // call the md5 method and convert king to md5

Callback function. one function calls another function, but it is implemented through the method called by the variable function. The system provides two methods: call_user_func (), call_user_func_array (), the difference between the two is that the former parameter is transmitted one by one, and the latter parameter is transmitted as an array. Example:

FunctionsayName ($ val) {echo "My name is {$ val}";} functiondoWhat ($ myFunction, $ name) {$ myFunction ($ name );} $ name = "King"; doWhat ("sayName", $ name); // output: My name is King.

Copyright Disclaimer: This article is an original article, and the Reprinted article must indicate the source. the viewpoint of this article only represents the current opinion, which must be insufficient. thank you very much for your attention!

The above introduces the php learning NOTE _ function type, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.

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.