PHP Variable function

In the previous variable section, we learned about variable variables. A variable function is just a variant of a variable, a variant expression.

Variable functions, we will also call them variable functions. A brief review of the previous knowledge points:

<?php
$hello = 'world';
$world = 'Hello';
/ / The output is: Hello
Echo $$hello; 
?>
Because $hello was first interpreted as world, then the world before the $ character is output: Hello.

The use of variable functions is this:

<?php
Function demo(){
    Echo '天王盖地虎';
}
Function test(){
    Echo 'chicken stewed mushrooms';
}
$fu = 'demo';
// Turn $fu into a demo, add a parenthesis after the demo, and execute the function.
$fu();
//Change the value of $fu to the test string and try again?
?>

It is recommended that in the basic grammar stage, you should not think about the final processing scenario, because the final processing scenario tells everyone that there is no grammatical basis and you will not understand. 

For example: a variable function, also called a variable function. Can be used in future MVC, object-oriented design patterns, etc. So don't go to the bottom.

Last Updated: 2018-07-06 12:32:44 By akshay

SHARE THIS

share_facebook share_twitter share_google_plus

Please Comment Here :