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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to