About function
Moderator: General Moderators
-
classic037
- Forum Newbie
- Posts: 4
- Joined: Sun Jan 14, 2007 11:23 pm
- Location: Mumbai
- Contact:
About function
Hi,
any one tell how many parameter we pass in php userdefine function.
any one tell how many parameter we pass in php userdefine function.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Search for userdefined() in PHP manual
I don't know of a "userdefine" function in PHP. Are you sure that is what it is called?
I don't know of a "userdefine" function in PHP. Are you sure that is what it is called?
(#10850)
-
classic037
- Forum Newbie
- Posts: 4
- Joined: Sun Jan 14, 2007 11:23 pm
- Location: Mumbai
- Contact:
hi,
user define function means function which is created by user..
i m taking about...
now how many parameter (like in code.. $var1,$var2,......) we pass in function..
user define function means function which is created by user..
i m taking about...
Code: Select all
function <name>([$var1 [= constant]],
[$var2 [= constant]], ...) {
}I think he's asking for a function that returns the number of expected arguments. For example:
He wants a function returns 3, because it's expecting 3 arguments.
As far as I know it's not possible.
Code: Select all
function userDefinedFunction($var1, $var2, $var3) {
//Blah blah blah
}As far as I know it's not possible.
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
Re: About function
As many parameters you have defined in your function.classic037 wrote:Hi,
any one tell how many parameter we pass in php userdefine function.
Suppose, you have
Code: Select all
function x($a, $b, $c=NULL){
}
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
The actual answer is: an unlimited amount.
Use func_get_args() inside your function to return an array of arguments passed to it.
Use func_get_args() inside your function to return an array of arguments passed to it.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
If this is the case, reflection can do it.onion2k wrote:I think he's asking for a function that returns the number of expected arguments. For example:He wants a function returns 3, because it's expecting 3 arguments.Code: Select all
function userDefinedFunction($var1, $var2, $var3) { //Blah blah blah }
As far as I know it's not possible.
http://php.net/language.oop5.reflection ... onfunction
Note ReflectionFunction::getNumberOfRequiredParameters()