Check out the manual section on default parameters...
But the basics are:
function top($image = "null") {
if ($image)
...
else
...
}
Or maybe:
That will set image to be null, so that you can call top either as:
top();
or
top($someimage);
-----Original Message-----
From: sunny AT wde [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 24, 2001 9:58 AM
To: php
Subject: [PHP] how do i give optional arguments to functions??
hi all!!
i'm writing functions like -
-------
function top () {
echo "blah blah blah";}
-------
what i want to do is make it so that i can do -
-------
function top($image) {
echo "blah blah $image blah"; }
-------
but also make the $image parameter in the top() as optional. so if
its not there, then tell php not to worry about it.
any ideas??
thanks!
sunny
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]