PHP outputs all the variables/constants/modules/functions/classes of the current process. Example _ php instance

Source: Internet
Author: User
PHP outputs all variables, constants, modules, functions, and classes of the current process. 1. get_defined_vars(PHP 4> = 4.0.4, PHP 5)-Get an array composed of all defined Variables
Array get_defined_vars (void)
This function returns a multidimensional array containing the list of all Defined variables, including environment variables, server variables, and User-Defined variables.

The Code is as follows:


Echo'

';
$ B = array );
$ 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 indicates that it is null and no parameter is 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

The Code is as follows:


Echo'

';
Print_r (get_loaded_extensions ());
?>


4. get_extension_funcs(PHP 4, PHP 5)-obtain available functions of a specified Module
Array get_extension_funcs (string $ module_name) This function returns all available functions of the specified module. The input parameter (Module name) must be in lowercase.

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 associated arrays, all constants, and their values
Array get_defined_constants ([bool $ categorize = false])

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 composed of the names of the defined classes
Array get_declared_classes (void)

The Code is as follows:


Echo'

';
//define classone
class classone { }
//define classtwo
class classtwo { }
//This will show X classes (built-ins, extensions etc) with
//classone and classtwo as the last two elements
print_r(get_declared_classes());
//define classthree
class classthree { }
//...and four
class classfour { }
//Shows the same result as before with class three and four appended
print_r(get_declared_classes());
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.