Folks,
Out of these followings, which is correct way to echo all $GLOBALs ?
1
<?php
$x5 = 9; //'Global Variable' as outside function. It now exists in "Super Global" Variable array as: $GLOBALS['x5'].
$y5 = 10; //'Global Variable' as outside function. It now exists in "Super Global" Variable array as: $GLOBALS['y5'].
echo "<pre>";
print_r($GLOBALS);
echo "</pre>";
?>
2
<?php
$x5 = 9; //'Global Variable' as outside function. It now exists in "Super Global" Variable array as: $GLOBALS['x5'].
$y5 = 10; //'Global Variable' as outside function. It now exists in "Super Global" Variable array as: $GLOBALS['y5'].
foreach($GLOBALS as $GLOBAL)
{
echo "<pre>";
print_r($GLOBAL);
echo "</pre>";
}
?>
3
<?php
$x5 = 9; //'Global Variable' as outside function. It now exists in "Super Global" Variable array as: $GLOBALS['x5'].
$y5 = 10; //'Global Variable' as outside function. It now exists in "Super Global" Variable array as: $GLOBALS['y5'].
foreach($GLOBALS as $GLOBAL)
{
echo "<pre>";
echo $GLOBAL; echo '<br>';
echo "<pre>";
}
?>
4
<?php
$x5 = 9; //'Global Variable' as outside function. It now exists in "Super Global" Variable array as: $GLOBALS['x5'].
$y5 = 10; //'Global Variable' as outside function. It now exists in "Super Global" Variable array as: $GLOBALS['y5'].
foreach($GLOBALS as $GLOBAL)
{
echo $GLOBAL; echo '<br>';
}
?>