Re: optional object arguments to a function
| From: | Michael A. Peters | Date: | Sun, 14 Feb 2010 07:53:33 +0000 |
| Subject: | Re: optional object arguments to a function | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302080@lists.php.net to get a copy of this message | ||
Rene Veerman wrote:
On Sat, Feb 13, 2010 at 9:05 AM, Michael A. Peters <mpeters@mac.com> wrote:Thank you to everybody. I think I will see how far I can get with func_get_arg - it may solve the problem. The other hackish solution I thought of is to put the object arguments into a key/value array and pass the array as a single argument to the function. That way I can check for the key and if the key is set, grab the object associated with it.How do I specify a default null object, or otherwise make the argument argument optional?To my knowledge: can't be done. But you can check any args through the func_get_arg*() functions, then per-parameter push 'm through a check function that checks if their primary properties are set. It's equivalent to checking for null ( / bad) objects.