Re: Skipping function arguments!
| From: | Marek Kilimajer | Date: | Thu, 28 Apr 2005 12:26:28 +0000 |
| Subject: | Re: Skipping function arguments! | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-214079@lists.php.net to get a copy of this message | ||
Bostjan Skufca @ domenca.com wrote:
function add ($a=1, $b=2, $c=3) {returns 2, OP wants 4 IMOreturn $a + $b + $c;} add(1, null, 1); will do just fine
r., Bostjan On Thursday 28 April 2005 14:16, Marek Kilimajer wrote:Vedanta Barooah wrote:Hello All, Cosider this : function add($a=1,$b=2,$c=3){php does not support this. you can workaround this using: function add($a = null,$b = null, $c = null){ if(is_null($a)) $a = 1; if(is_null($b)) $b = 2; if(is_null($c)) $c = 3;return $a + $b + $c;} how do i skip the second argument while calling the function, is there a process like this: echo add(1,,1); # where i expect 2 to be printed,return $a + $b + $c;} add(1, null, 1);