Jump to content


Photo

calling functions using parameter names


  • Please log in to reply
1 reply to this topic

#1 mattgleeson

mattgleeson
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 31 July 2006 - 11:32 AM

Hi
New to the forum, so sorry in advance if this question is supposed to be in another forum.
I have created a function containing some parameters and now want to call this function but only pass in some parameters using the the parameter's name. i.e.
function someFunction($paramA=NULL, $paramB=NULL, $paramC=NULL){
return NULL;
}

//in my code somwhere i want to do something along the lines of:
$variable = someFunction($paramB=>"value");

Is this possible?

Cheers

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 31 July 2006 - 01:43 PM

No I dont think this is possible. However when creating your own functions, you should first start of by listing the parameters for that function and then order those parameters in order of priority. You shouldn't create a function which has sometihng like 10+ parameters, otherwsie the order of prority becomes harder to work out, the max paramters I'd say a function should have is 5.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users