optional object arguments to a function

From: Date: Sat, 13 Feb 2010 08:05:22 +0000
Subject: optional object arguments to a function
Groups: php.general 
Request: Send a blank email to php-general+get-302059@lists.php.net to get a copy of this message
I've started working on a class using DOMDocument to assemble MathML in php. The class, assuming I actually succeed, will eventually be used for parsing LaTeX math equations to MathML without the need to have TeX installed. I probably won't be able to support all the possibilities for equations that LaTeX does w/o a TeX install (and definitely not user defined macros) but I suspect I can (hopefully) cover most of the common stuff. One thing I don't know how to do, though, is write a function where arguments are optional object. IE for a function to generate an integral, the limits are optional but if specified must be an object (since they may be an equation themselves). I want the default to be some kind of a null object so I know to do nothing with it if it is null. With string/integer you just do function foo($a='',$b='',$c=false) { } How do I specify a default null object, or otherwise make the argument argument optional?

« previous php.general (#302059) next »