如何获取当前范围/符号表中定义的所有变量? [英] How to get all variables defined in the current scope/symbol table?

查看:27
本文介绍了如何获取当前范围/符号表中定义的所有变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP 中是否有函数和/或对象和/或扩展可以让您查看当前作用域中定义的所有变量?类似的东西:

Is there a function and/or object and/or extension in PHP that will let you view all the variables defined in the current scope? Something like:

var_export($GLOBALS)

但只显示当前符号表中的变量.

but only showing variables in the current symbol table.

推荐答案

get_defined_vars

此函数返回一个多维数组,其中包含所有定义变量的列表,包括环境变量、服务器变量或用户定义变量,在 get_defined_vars() 的范围内叫.

This function returns a multidimensional array containing a list of all defined variables, be them environment, server or user-defined variables, within the scope that get_defined_vars() is called.

这篇关于如何获取当前范围/符号表中定义的所有变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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