Re: Calling functions by reference

From: Date: Wed, 04 Oct 2000 01:20:26 +0000
Subject: Re: Calling functions by reference
Groups: php.general 
Request: Send a blank email to php-general+get-18497@lists.php.net to get a copy of this message
Addressed to: cjsmith@btinternet.com php-general@lists.php.net ** Reply to note from cjsmith@btinternet.com Tue, 3 Oct 2000 15:45:36 00100 > > Hi, > > I am trying to write a function that has parameters passed by reference, > and was wondering how to get a default value to them. > > e.g.: function test(&$a, &$b = 0) > Sorry, you can't have a by reference that has a default value. If you want to mix then, the by reference params have to come before the optional params. function test( &$a, $b = 0 ) will work. You always have to pass something to a by reference parameter, but you could check it for a known empty value (0 or '' ) and set your default. if( '' == $a ) $a = 'default value'; Rick Widmer Internet Marketing Specialists www.developersdesk.com

« previous php.general (#18497) next »