Re: Optional pass-by-reference parameters?

From: Date: Tue, 28 Feb 2006 05:33:54 +0000
Subject: Re: Optional pass-by-reference parameters?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-231183@lists.php.net to get a copy of this message
If "some_func( &$var = NULL )" didn't work, then you're most likely using PHP 4. If that's the case then you could try passing an argument by reference in call(real/execution)-time, e.g: function some_func( $optional = NULL ) {
    ···
} some_func(); some_func(&$my_var); Note: beware that the directive "allow_call_time_pass_reference"
      _must_ be On in your php.ini
      This functionality is deprecated, since PHP 5 does allow
      optional arguments-by-reference.
TomS wrote:
I would like to have an optional pass-by-reference. i.e. you can call the function w/o the variable. Basically, like how you don't need to pass $matches to the preg_match function. I've tried, function some_func(&$var = null) and this doesn't work. func_get_args only gets copies, does anyone have any other solutions? -- Atentamente, J. Rafael Salazar Magaña Innox - Innovación Inteligente Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE http://www.innox.com.mx


« previous php.general (#231183) next »