Re: Custom function

From: Date: Wed, 16 Feb 2011 20:00:09 +0000
Subject: Re: Custom function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-311385@lists.php.net to get a copy of this message
In my code, I set the optional parameter to NULL and check for triple equals "===" or "!==" to see if the variable has been passed with a value. IMO, this is the safest way. function MyFunction($x, $y, $z=NULL) { if ($z !== NULL) { // Do Something } } Dan Schaefer Web Developer/Systems Analyst Performance Administration Corp. On 2-15-2011 6:32 PM, Ron Piggott wrote:
Is there a way to make an optional flag in a custom function --- 2 parameters required, 1 optional? Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info


« previous php.general (#311385) next »