|
Posted by Jerry Stuckle on 11/29/06 13:03
Thomas Mlynarczyk wrote:
> Also sprach Jerry Stuckle:
>
>
>>>$someArray = array('field1' => 1, 'field2' => 'two');
>
>
>>>$someArray = array();
>>>$someArray['field1'] = 1;
>>>$someArray['field2'] = 'two';
>
>
>>Actually, the second option is perfectly valid. It's fine to assign
>>to an array element which hasn't been defined yet. Just don't try to
>>USE an array element (or any other variable) before it's been defined.
>
>
> Come to think of it:
> $GLOBALS['notDefinedYet']
> and
> global $notDefinedYet
>
> The first would give a notice, the second one not. I thought I had read
> something about this difference in the manual, but can't find it again.
>
> Also, I have heard about a security issue concerning $GLOBALS: that in some
> versions of PHP, it is (was?) possible to overwrite the complete array by
> passing a request parameter 'GLOBALS' to the script. Would the global
> keyword also be concerned here?
>
> Greetings,
> Thomas
>
>
>
$GLOBALS['notDefinedYet'] = $x;
will not give a notice.
$x = $GLOBALS['notDefinedYet'];
will. See the difference?
And
global($notDefinedYet);
Doesn't actually use the value. It just declares it to be global.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|