是否可以在PHP中列出所有全局变量?

时间:2020-12-30 23:36:03

Is it possible to list out all the Global Variable. Such , as to print all session variable we can use print_r($_SESSION); as the same way, if i want to know how many Global variables are define in my site. is it possible? Please Help.

是否可以列出所有全局变量。这样,为了打印所有会话变量,我们可以使用print_r($ _ SESSION);同样地,如果我想知道在我的网站中定义了多少全局变量。可能吗?请帮忙。

I need the list which can show me all the Global variables List in PHP.

我需要列表,它可以显示PHP中的所有全局变量列表。

5 个解决方案

#1


18  

Yes, PHP $GLOBALS array will show you.

是的,PHP $ GLOBALS数组会告诉你。

<?php

echo "<pre>";
print_r($GLOBALS);
echo "</pre>";

#2


6  

To get names of all global variables do this:

要获取所有全局变量的名称,请执行以下操作

array_keys($GLOBALS)

More docs:

#3


3  

$GLOBALS — References all variables available in global scope also check this PHP global or $GLOBALS here you find many important and useful thing about $GLOBALS

$ GLOBALS - 引用全局范围内可用的所有变量也检查这个PHP全局或$ GLOBALS这里你发现很多关于$ GLOBALS的重要和有用的东西

#4


2  

The reserved $GLOBALS variable is an array containing all global variables.

保留的$ GLOBALS变量是一个包含所有全局变量的数组。

In the array, the keys are variable names and the values are variable values.

在数组中,键是变量名,值是变量值。

#5


2  

Well, there does exist a $GLOBALS variable in PHP.

好吧,PHP中确实存在$ GLOBALS变量。

But you can't do a var_export() on it. It'll lead to an error like: Nesting level too deep - recursive dependency?

但你不能对它做一个var_export()。它会导致一个错误:嵌套级别太深 - 递归依赖?

#1


18  

Yes, PHP $GLOBALS array will show you.

是的,PHP $ GLOBALS数组会告诉你。

<?php

echo "<pre>";
print_r($GLOBALS);
echo "</pre>";

#2


6  

To get names of all global variables do this:

要获取所有全局变量的名称,请执行以下操作

array_keys($GLOBALS)

More docs:

#3


3  

$GLOBALS — References all variables available in global scope also check this PHP global or $GLOBALS here you find many important and useful thing about $GLOBALS

$ GLOBALS - 引用全局范围内可用的所有变量也检查这个PHP全局或$ GLOBALS这里你发现很多关于$ GLOBALS的重要和有用的东西

#4


2  

The reserved $GLOBALS variable is an array containing all global variables.

保留的$ GLOBALS变量是一个包含所有全局变量的数组。

In the array, the keys are variable names and the values are variable values.

在数组中,键是变量名,值是变量值。

#5


2  

Well, there does exist a $GLOBALS variable in PHP.

好吧,PHP中确实存在$ GLOBALS变量。

But you can't do a var_export() on it. It'll lead to an error like: Nesting level too deep - recursive dependency?

但你不能对它做一个var_export()。它会导致一个错误:嵌套级别太深 - 递归依赖?