Re: Weird behaviour with references to objects...

From: Date: Fri, 08 Nov 2002 16:08:43 +0000
Subject: Re: Weird behaviour with references to objects...
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-123404@lists.php.net to get a copy of this message
At 17:04 08.11.2002, Tim Molendijk spoke out and said: --------------------[snip]-------------------- >Yes I know it is poor programming habits to do like I did... But I have a >reason for it. I have quite a lot methods that accept objects *optional*. So >f.e.: >--- >class Product >{ > var $language; > function Product($language = FALSE) > { > $this->language = $language; > } >} >--- >Now to make this possible it becomes impossible to do what you suggest: >function Product(&$language = FALSE) >is not allowed. And in my application this optional arguments functionality >is very important. So I have preferred this over the decent habit. --------------------[snip]-------------------- You might always simply omit the parameter when calling the function (you'll get a notice about that if enabled). You just cannot pass constants: function Product(&$language) { ... } // ok, but gives a notice Product(); // will fail Product('ger'); If you keep your code like it is be warned that it may break with a future version of PHP. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#123404) next »