php 获取所有用户定义的变量的列表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 获取所有用户定义的变量的列表相关的知识,希望对你有一定的参考价值。

<?php
       // list of keys to ignore (including the name of this variable)
        $ignore = array('GLOBALS', '_FILES', '_COOKIE',  '_POST', '_GET', '_SERVER', '_ENV', 'ignore');
        // diff the ignore list as keys after merging any missing ones with the defined list
        $vars = array_diff_key(get_defined_vars() + array_flip($ignore), array_flip($ignore));
        // should be left with the user defined var(s) (in this case $testVar)
        var_dump($vars);

以上是关于php 获取所有用户定义的变量的列表的主要内容,如果未能解决你的问题,请参考以下文章