Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #12884
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Declaring an array necessary? |
| Date | 2014-02-21 22:58 +0100 |
| Message-ID | <bmq0gtF5t8gU1@mid.uni-berlin.de> (permalink) |
| References | <le840m$8kk$1@news.albasani.net> |
Am 21.02.2014 18:56, schrieb The Natural Philosopher: > I was just wondering. Php assumes a varibale exists as soon as it is assigned a > value, but a function exists to create an array.. I would rather say: PHP creates a variable as soon as you assign a value to one that does not exist. > Sop can one just say > > $arr['hello']='sexy'; > > or should there be > > $arr=array(); > > first? > I would do a $arr = array() before I start to store data from the database into it, because a query could give zero records, and I don't want my script killed on the next foreach. There is redundancy in many programming languages, in the sense that you can get the same result with several different expressions. So I would not worry too much about why array() exists. /Str.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Declaring an array necessary? The Natural Philosopher <tnp@invalid.invalid> - 2014-02-21 17:56 +0000
Re: Declaring an array necessary? Christian Stadler <stadli@gmx.de> - 2014-02-21 21:04 +0100
Re: Declaring an array necessary? Jerry Stuckle <jstucklex@attglobal.net> - 2014-02-21 15:48 -0500
Re: Declaring an array necessary? The Natural Philosopher <tnp@invalid.invalid> - 2014-02-21 21:32 +0000
Re: Declaring an array necessary? Gregor Kofler <usenet@gregorkofler.com> - 2014-02-21 22:55 +0100
Re: Declaring an array necessary? Tim Streater <timstreater@greenbee.net> - 2014-02-21 22:06 +0000
Re: Declaring an array necessary? "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2014-02-21 22:58 +0100
Re: Declaring an array necessary? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-02-21 14:03 -0800
csiph-web