Re: Speaking of Global Annoyance

From: Date: Fri, 22 Dec 2000 23:35:48 +0000
Subject: Re: Speaking of Global Annoyance
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-31634@lists.php.net to get a copy of this message
* Jonathan Sharp (webdev@flyerware.com) wrote: > or you could: > function getimages(){ > global $imagename; > ... > } > > and all you have to do is call the function... as getimages(); and > $imagename will be an array...thought this isn't the best way since you > start giving functions global scope...but it's kinda hard to return arrays > since you can't just do "return $thearray;" and then on the other end > "$anarray = somefunction();" I think this is exactly the kind of nastiness Rasmus etc. are trying to prevent. Functions that implicitly alter vars can be a bitch to debug. I think that: $imagenames = getimages(); is far superior to: getimages(); // this sets $imagenames So, as a person that has to work on other peoples code.. please use the former. :) so essentially, I agree. Mike -- Mike Erickson <mee(at)quidquam.com> http://www.quidquam.com/ "The more noise a man or a motor makes the less power there is available." - W. R. McGeary

« previous php.general (#31634) next »