Hi.
I wonder how i should do to have parameters optional and not required
for custom functions, like some of the built in function.
For example.
for my site i have this function called:
send_message( $message, $notice ), where $notice should be a optional parameter.
It simply draws a message on screen.
Now, if it is a warning you should set parameter 2 to:
1 = notice,
2 = varning,
3 = critical
If i leave $notice blank it just gives me the "wrong parameter count for function..." message.
Thank you for your time,
Best Regards,
Owe Blomqvist
Optional parameters for custom functions.
Moderator: General Moderators
-
Owe Blomqvist
- Forum Commoner
- Posts: 33
- Joined: Wed Oct 16, 2002 2:27 pm
Code: Select all
function test($required,$not_required='') {
........
}Code: Select all
test('hallo');
test ('hallo','world');if your function is documented well you migh consider using http://www.php.net/manual/en/function.func-num-args.php
Without a proper doc this gets quite confusing
Without a proper doc this gets quite confusing
-
Owe Blomqvist
- Forum Commoner
- Posts: 33
- Joined: Wed Oct 16, 2002 2:27 pm