Home >Backend Development >PHP Tutorial >Example of PHP outputting all variables/constants/modules/functions/classes of the current process_PHP tutorial
1. get_defined_vars (PHP 4 >= 4.0.4, PHP 5) — Get an array consisting of all defined variables
array get_defined_vars (void)
This function returns an array containing all Multidimensional array of a list of defined variables, including environment variables, server variables, and user-defined variables.
';<br> $b = array(1,1,2,3,5,8);<br>$arr = get_defined_vars();<br>// Print $b<br>print_r($arr["b"]); <br>//Print all server variables<br>print_r($arr["_SERVER"]);<br>//Print all available key values of the variable array<br>print_r(array_keys(get_defined_vars()));<br>?><br><strong>2. get_defined_functions</strong> (PHP 4 >= 4.0.4, PHP 5) — Get all defined functions<br>array get_defined_functions (void) //void is expressed as Empty, no parameters are required<br><?php <BR>echo '<pre class="brush:php;toolbar:false">';<br>function foo()<br>{<br> echo "This is my function foo";<br> }<br>$arr = get_defined_functions();<br>print_r($arr);<br>?><br>
';<br>print_r(get_extension_funcs("gd"));<br>print_r(get_extension_funcs("xml"));<br>?><br>
';<br>define( "MY_CONSTANT", 1);<br>print_r(get_defined_constants(true));<br>?><br>
';<br>//define classone<br>class classone { }<br>//define classtwo<br>class classtwo { }<br>//This will show <br>//...and four<br>class classfour { }<br>//Shows the same result as before with class three and four appended<br>print_r(get_declared_classes());<br>?> <br><br> <br> <br><br>
www.bkjia.com