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.
';
$b = array(1,1,2,3,5,8);
$arr = get_defined_vars();
// Print $b
print_r($arr["b"]);
//Print all server variables
print_r($arr["_SERVER"]);
//Print all available key values of the variable array
print_r(array_keys(get_defined_vars()));
?>
2. get_defined_functions (PHP 4 >= 4.0.4, PHP 5) — Get all defined functions
array get_defined_functions (void) //void is expressed as Empty, no parameters are required
echo '';
function foo()
{
echo "This is my function foo";
}
$arr = get_defined_functions();
print_r($arr);
?>
';
print_r(get_extension_funcs("gd"));
print_r(get_extension_funcs("xml"));
?>
';
define( "MY_CONSTANT", 1);
print_r(get_defined_constants(true));
?>
';
//define classone
class classone { }
//define classtwo
class classtwo { }
//This will show
//...and four
class classfour { }
//Shows the same result as before with class three and four appended
print_r(get_declared_classes());
?>
www.bkjia.com