: 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.