[thelist] functions in PHP and arguments (was: PHP string tip...)

Charles F. Johnson charles at littlegreenfootballs.com
Fri Aug 31 20:40:10 CDT 2001


Joe Crawford <jcrawford at avencom.com> typed:

> So *this* is the way to make arguments optional in PHP? This is
> something that has bothered me for a while - how to make a function with
> optional arguments.

To split hairs a bit, this method of calling a function doesn't make the
argument optional; it gives it a default value if none is passed.

> And how would I make a function with an arbitrary number of arguments?
> like in JavaScript where you can access a functioname.arguments[] array.

You can do this by using func_num_args(), func_get_arg(), and
func_get_args().

charles johnson
lgf web design
http://littlegreenfootballs.com





More information about the thelist mailing list