PHP设置$ GLOBALS产生空白结果

Is there a problem setting a global variable ?

This is INSIDE a function, & in a foreach loop. These three lines are one after the other (it does not go anywhere else)...

    $GLOBALS["nameaa"]=$abl;
    $search_array_log.= "  ADDING GLOBALS NAME - '$ab1'
";
    $search_array_log.= " GLOBAL NAME1 NOWAa '".$GLOBALS["nameaa"]."'
";

But when viewing the $search_array_log data afterwards, the GLOBALS value isnt set.. - its a blank result...

I tried name & thought it may be a reserved word, so changed to nameaa but the $GLOBALS["nameaa"] is still blank.

I do know there may be some issues / processes to follow to send data in/out of functions... But these three lines are in the same code - No going in/out (as yet) of the function...

Can anyone advise as to what may be the cause as to why this $GLOBALS isnt being set ??

Ps $search_array_log is being saved/recorded for everything before/after these three lines - its a long text file / log file.

EDIT: $ab1 does exist as a value & is shown in my logs - ADDING GLOBALS NAME - $ab1.

A variable outside function is a global variable like

<?php
$abc = 10; //global var
function foo {
     global $abc; // to use global variable inside function
}
?>

Hope it help.