Home > Backend Development > PHP Tutorial > Example of PHP outputting all variables/constants/modules/functions/classes of the current process_PHP tutorial

Example of PHP outputting all variables/constants/modules/functions/classes of the current process_PHP tutorial

WBOY
Release: 2016-07-13 10:25:27
Original
865 people have browsed it

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.

Copy code The code is as follows:

echo '
';
$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);
?>

3. get_loaded_extensions (PHP 4, PHP 5 ) — Get all available modules
Copy code The code is as follows:

echo '< pre>';
print_r(get_loaded_extensions());
?>

4. get_extension_funcs (PHP 4, PHP 5) — Get the specified module Available functions
array get_extension_funcs ( string $module_name ) This function returns all available functions of the specified module. The passed-in parameters (module name) must be lowercase
Copy code The code is as follows:

echo '
';
print_r(get_extension_funcs("gd"));
print_r(get_extension_funcs("xml"));
?>

5. get_defined_constants (PHP 4 >= 4.1.0, PHP 5) — Get the names of all constants and their values ​​in an associative array
array get_defined_constants ([ bool $categorize = false ] )
Copy code The code is as follows:

echo '
';
define( "MY_CONSTANT", 1);
print_r(get_defined_constants(true));
?>

6. get_declared_classes (PHP 4, PHP 5) — Get an array consisting of the names of defined classes
array get_declared_classes (void)
Copy code The code is as follows:

echo '
';
//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());
?>




http://www.bkjia.com/PHPjc/825077.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/825077.htmlTechArticle1. get_defined_vars (PHP 4 = 4.0.4, PHP 5) — Get a list of all defined variables Array array get_defined_vars (void) This function returns a list containing all defined variables...
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template