Re: what is the meaning
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 20:57:47 -0500
NC wrote:
Thomas Mlynarczyk wrote:
sam wrote:
What is the meaning of this operator:-
=>
Assignment - used in arrays?
Hm. But why the need for a special operator here? Wouldn't
a simple = have done the job just as well?
Yes, but you'd have to write it differently.
Consider this simple example:
$someArray = array('field1' => 1, 'field2' => 'two');
If it equivalent to:
$someArray = array();
$someArray['field1'] = 1;
$someArray['field2'] = 'two';
Moreover, the second option might trigger an E_NOTICE, since
you would be trying to assign a value to a not-yet-defined member
of the array...
Cheers, NC
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.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: what is the meaning
- From: Thomas Mlynarczyk
- Re: what is the meaning
- Prev by Date: Re: php form help
- Next by Date: Re: Install
- Previous by thread: Install
- Next by thread: Re: what is the meaning
- Index(es):