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
gautamz07
Forum Contributor
Posts: 331 Joined: Wed May 14, 2014 12:18 pm
Post
by gautamz07 » Fri Nov 21, 2014 11:03 am
Code: Select all
public function world($arg = false){
echo "We are the world !!" . '<br>';
echo "Optional: " . $arg . '<br>';
}
in the above code why $ args==false ?? why not just a normal variable like $temp , any advantage of doing it this way ??
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Fri Nov 21, 2014 11:10 am
Optional arguments require a default value. Could have been null, 12, 'apple'. Doesn't much matter.