PHP custom function variable function
In the previous variable section, we learned about variable variables. Variable function is just a variant and deformed expression of variable variable.
Variable function, we will also call it variable function. A brief review of the previous knowledge points:
<?php $hello = 'world'; $world = '你好'; //輸出的結(jié)果為:你好 echo $$hello; ?>
Because $hello is first interpreted as world, and then the $ sign is added before world to output: Hello.
The usage of variable functions is like this:
<?php function demo(){ echo '天王蓋地虎'; } function test(){ echo '小雞燉蘑菇'; } $fu = 'demo'; //把$fu變?yōu)榱薲emo,把demo后加上了一個括號,就執(zhí)行函數(shù)了 $fu(); //把$fu的值改為test字符串再試試? ?>
It is recommended that when you are learning basic grammar, you should not think about the final processing scenario, because the final processing scenario has been told to you. If you don’t have a grammatical foundation, you won’t understand.
For example: variable function, also called variable function. It can be used in future MVC, object-oriented design patterns, etc. So, don’t delve into it now.