Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Gustav Wiberg
- Original Message - From: Mark Steudel [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Friday, March 03, 2006 7:46 PM Subject: [PHP] Coding Practice: Use global $var or pass in by refernce I was wondering what the general rule on using the global driective versus passing in a

Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Andreas Korthaus
Hi Gustav! Gustav Wiberg wrote: My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it! Ok, so what's your recommendation to solve the

Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Luis MagaƱa
I would go for: - you can create a new instance (new DB) in every methode (but you usually only want a single DB-connection per script, and where do you pass config-data to access the DB?) or This way the code keeps well organized and about the use of only one connection I wouldn't worry

Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Gustav Wiberg
- Original Message - From: Andreas Korthaus [EMAIL PROTECTED] To: php-general@lists.php.net; Gustav Wiberg [EMAIL PROTECTED] Sent: Friday, March 03, 2006 8:53 PM Subject: Re: [PHP] Coding Practice: Use global $var or pass in by refernce Hi Gustav! Gustav Wiberg wrote: My oponion

Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Robert Cummings
On Fri, 2006-03-03 at 14:53, Andreas Korthaus wrote: - use a factory/singleton, which is not so much better than a global variable (and again, what about config-data?). I use a global configuration to register database connection params. InterJinn uses something like the following:

Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread tedd
So what's the way [using Globals] you'd recommend and why? best regards Andreas Andreas: I have to agree with Gustav on this -- I very seldom use Globals. I might use one for debugging, but not for finished code. Their use simply creates problems in porting code, keeping things modular, and

Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Rafael
Andreas Korthaus wrote: Hi Gustav! Gustav Wiberg wrote: My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it! Ok, so what's your

Re: [PHP] Coding Practice: Use global $var or pass in by refernce

2006-03-03 Thread Paul Scott
On Fri, 2006-03-03 at 16:19 -0500, tedd wrote: Perhaps I'm fortunate, but I usually find a way around using Globals. And since I've been coding in PHP, I've never been forced to use them. Just my 2c... In our framework, I use globals as well, although I do tend to agree with Tedd regarding