[SOLVED] =0 in function??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
melindaSA
Forum Commoner
Posts: 99
Joined: Thu Oct 02, 2003 7:34 am

[SOLVED] =0 in function??

Post by melindaSA »

Quick question, what does the =0 in

Code: Select all

function send_mail($what, $who, $sender_name=0, $code=0)
do??
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

It sets a default value for that variable if a value isn't passed in.
E.g

function foo($required, $optional1=0, $optional2=5){
echo $optional1.' '.$optional2;
}

foo(1); //displays 0 5
foo(1, 7); //displays 7 5
foo(1,6,6); // displays 6 6
melindaSA
Forum Commoner
Posts: 99
Joined: Thu Oct 02, 2003 7:34 am

Post by melindaSA »

Thank you, makes sense now! :D
Post Reply