As discussed earlier, variables inside a function exist inside a name space separate from the global name space. Variables inside a function are private property and may never be seen or manipulated outside the function. However, there are two ways a function may access variables in the global scope: the global statement and the GLOBALS array.
The global statement brings a variable into a function's name space. Thereafter the variable may be used as if it were outside the function. Any changes to the variable will persist after execution of the function ceases. In the same way, it is possible to refer to global variables through the array GLOBALS. The array is indexed by variable names, so if you create a variable named userName you can manipulate it inside a function by writing $GLOBALS["userName"].
If a variable is declared to be static, it retains its value between function calls. demonstrates the use of static variables.
PHP Related Interview Questions
|PHP Interview Questions||MySQL Interview Questions|
|PHP+MySQL Interview Questions||Drupal Interview Questions|
|MYSQL DBA Interview Questions||PHP5 Interview Questions|
|WordPress Interview Questions||Joomla Interview Questions|
|CakePHP Interview Questions||CodeIgniter Interview Questions|
|PHP7 Interview Questions|
An Introduction To Php
Variables, Operators, And Expressions
Classes And Objects
I/o And Disk Access
Time, Date, And Configuration Functions
Parsing And String Evaluation
Sorting Searching And Random Numbers
Integration With Html
Efficiency And Debugging
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.