Hello Peter, So is func_get_args() the unique way? -- With best regards from Ukraine, Andre Skype: Francophile My blog: http://oire.org/menelion (mostly in Russian) Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion ------------ Original message ------------ From: Peter Lind <peter.e.lind@xxxxxxxxx> To: Dan Schaefer Date created: , 10:21:20 PM Subject: Custom function On 16 February 2011 21:00, Dan Schaefer <dan@xxxxxxxxxxxxxxxxxxxx> wrote: > 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 > } > } In case you're actually trying to test if a variable was passed or not that doesn't work (as it doesn't detect NULL passed in). Use func_get_args() as that gives you any and all arguments passed to the function, excluding defaults. That said, if you're making use of optional parameters and need to check if anything was passed in, you're almost certainly doing things wrong. Regards Peter -- <hype> WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 </hype> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php