• PHP Video Tutorials

PHP - get_defined_vars() Function


Advertisements

Definition and Usage

The function get_defined_vars() returns array of all defined variables.

Syntax

array get_defined_vars ()

Parameters

None

Return Values

This function returns a multidimensional array containing a list of all defined variables.

Dependencies

PHP 4.0.4 and above.

Example

Following example demonstrates use of get_defined_vars() function −

<?php
   // Declare an array and initialize it
   $a = array(0, 1, 2, 3, 4);
   // Use get_defined_vars() function
   $arr = get_defined_vars();

   // print $arr
   print_r($arr);
?>

Output

This will produce following result −

Array (
[_GET] => Array ( )
[_POST] => Array ( )
[_COOKIE] => Array ( )
[_FILES] => Array ( )
[a] => Array (
   [0] => 0
   [1] => 1
   [2] => 2
   [3] => 3
   [4] => 4
))

As you can see this function returns a multidimensional array containing a list of all defined variables (environment, server or user-defined variables) within the scope that get_defined_vars() is called.

php_variable_handling_functions.htm

Useful Video Courses


Video

PHP Online Training

45 Lectures 9 hours

Malhar Lathkar

Video

Become PHP Facebook Developer: Password-Less Authentication

34 Lectures 4 hours

Syed Raza

Video

Ultimate PHP & MySQL Web Development Course & OOP Coding

84 Lectures 5.5 hours

Frahaan Hussain

Video

Learn PHP from Scratch

17 Lectures 1 hours

Nivedita Jain

Video

E Commerce Website Development In PHP With PDO

100 Lectures 34 hours

Azaz Patel

Video

PHP in Telugu

43 Lectures 5.5 hours

Vijay Kumar Parvatha Reddy

Advertisements