Re: Variable variables and references
| From: | Richard Lynch | Date: | Mon, 12 Mar 2007 23:36:22 +0000 |
| Subject: | Re: Variable variables and references | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250353@lists.php.net to get a copy of this message | ||
On Sat, March 10, 2007 6:28 am, Dave Goodchild wrote:
> Hi guys, I have just read 'Programming PHP' (O'Reilly) and although I
> think
> it's a great book, I am confused about variable variables and
> references -
> not the mechanics, just where you would use them.
>
> The subject of variable variables is explained but no examples are
> given as
> to why and where you would utilise them.
99% of the time, using variable variables means you screwed up and
should have used an array. :-)
The 1% remaining is something that should be attempted only by
experts, so you'll know when you get there that you need it.
> As for references, the examples given with regard to passing and
> returning
> by reference in functions is clear, but no real examples are given as
> to
> when this would be a preferred approcah - in fact, the authors stress
> that
> due to PHP's copy-on-write mechanism, it is not a frequently-used
> approcah.
In PHP5, the whole reference thing changed all around.
What version is the book targetted at, and what version are you running?
> So my question - are there any 'classic' situations in which either
> should
> be used, and where and when do you guys use them in your real-world
> efforts?
I don't even use OOP in PHP, much less &OOP.
I only used variable variables when I was young and foolish.
Well, younger and more foolish.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?