args = false ???

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
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

args = false ???

Post by gautamz07 »

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 ??
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: args = false ???

Post by Celauran »

Optional arguments require a default value. Could have been null, 12, 'apple'. Doesn't much matter.
Post Reply