PHP中的$$(美元或双美元)是什么意思? [英] What does $$ (dollar dollar or double dollar) mean in PHP?

查看:139
本文介绍了PHP中的$$(美元或双美元)是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例是函数内的变量声明:

Example is a variable declaration within a function:

global $$link;

$$是什么意思?

推荐答案

诸如 $$variable 之类的语法称为
例如,如果您考虑这部分代码:


For example, if you consider this portion of code :

$real_variable = 'test';
$name = 'real_variable';
echo $$name;

您将获得以下输出:

test


在这里:

  • $real_variable包含测试
  • $name包含变量的名称:'real_variable'
  • $$name的意思是"变量thas的名称包含在$name 中"
    • 哪个是$real_variable
    • 且值为'test'
    • $real_variable contains test
    • $name contains the name of your variable : 'real_variable'
    • $$name mean "the variable thas has its name contained in $name"
      • Which is $real_variable
      • And has the value 'test'


      正在执行$$$吗?
      嗯,最好的认识方法是尝试;-)

      Doing a $$$ ?
      Well, the best way to know is to try ;-)

      所以,让我们尝试这段代码:

      So, let's try this portion of code :

      $real_variable = 'test';
      $name = 'real_variable';
      $name_of_name = 'name';
      
      echo $name_of_name . '<br />';
      echo $$name_of_name . '<br />';
      echo $$$name_of_name . '<br />';
      

      这是我得到的输出:

      name
      real_variable
      test
      

      因此,我想说的是,是的,您可以执行$$$ ;-)

      So, I would say that, yes, you can do $$$ ;-)

      这篇关于PHP中的$$(美元或双美元)是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆