PHP $GLOBALS (super global) variable
Description
$GLOBAL is a php super global variable which can be used instead of 'global' keyword to access variables from global scope, i.e. the variables which can be accessed from anywhere in a php script even within functions or methods.
Here is an example to testify the theory mentioned above:
<?php
$s = 25;
$t = 50;
function subtraction()
{
$GLOBALS['v'] = $GLOBALS['t'] - $GLOBALS['s'];
}
subtraction();
echo $v;
?>
In the code above, since v is a variable present within $GLOBALS array,
it is accessible form outside the function also.
View the example of $GLOBALS variable in the browser
PHP: Tips of the Day
PHP: How to fix error with xml2-config not found when installing PHP from sources?
All you need to do instal install package libxml2-dev for example:
sudo apt-get install libxml2-dev
On CentOS/RHEL:
sudo yum install libxml2-devel
Ref : https://bit.ly/34hOrfG
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework