Saturday, August 19, 2017

How to use the super global variable $GLOBALS?

The example below shows how to use the super global variable $GLOBALS:

Example

<?php
$x = 75;
$y = 25;

function addition() {
    $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];
}

addition();
echo $z;
?>