Front-end PHP entry -011-variable function

Source: Internet
Author: User

Variable functions, which we also call variable functions. Briefly review the previous knowledge points:

  
 
    1. <?php
    2. $hello = ‘world‘;
    3. $world = ‘你好‘;
    4. //输出的结果为:你好
    5. echo $$hello;
    6. ?>

因为$hello先被解释成了world,再world前加上$符就输出了:你好。

The use of variable functions is this:

  
 
  1. <?php
  2. function demo(){
  3. echo ‘天王盖地虎‘;
  4. }
  5. function test(){
  6. echo ‘小鸡炖蘑菇‘;
  7. }
  8. $fu = ‘demo‘;
  9. //把$fu变为了demo,把demo后加上了一个括号,就执行函数了
  10. $fu();
  11. //把$fu的值改为test字符串再试试?
  12. ?>


From for notes (Wiz)

Front-end PHP entry -011-variable function

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.