Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  Optional arguments in PHP function

In PHP, we can define our own functions which can accept optional number of arguments. In this kind of functions, the optional argument should be set with default value.Fox example, the next code example will illustrate this:<?php function func($name,$type=NULL) { echo "$name $type"; } func("Hello"); echo "<br />"; func("Hello","world"); echo "<br />";?>Here $type is an optional argument. It must be set with a default value either NULL or some other value. Quite simple.Right! In other programming languages, we can achieve similar effects. This is very convenient if we...

4,469 0       PHP OPTIONAL ARGUMENTS USER DEFINED FUNC