RE: blank function parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

 when declaring function 


function example($var1, $var2, $var3, $var4="anything")
{


}

Now calling  
Example("one","two","three");
will not throw an error, but pass 'anything' as the value of $var4 by
default if you override the value pass all the argumets.

Zareef ahmed 

-----Original Message-----
From: Jay Blanchard [mailto:jay.blanchard@xxxxxxxxxxxxxxxxxxxxx] 
Sent: Wednesday, November 03, 2004 9:12 PM
To: Giles Roadnight; php-general@xxxxxxxxxxxxx
Subject: RE:  blank function parameters


[snip]
If I defined a function with 4 parameters but only pass 3 I get an
error. Is there anyway around this?
 
I want to be able to set the missing parameter to a default value if it
is not passed which works ok but How do I get rid of the error message?
[/snip]

http://us2.php.net/manual/en/function.func-num-args.php "func_num_args()
may be used in conjunction with func_get_arg() and func_get_args() to
allow user-defined functions to accept variable-length argument lists. "

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




------------------------------------------------------------------------
--
Zareef Ahmed :: A PHP develoepr in Delhi ( India )
Homepage :: http://www.zasaifi.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux