In C#, there is a new feature coming with 4.0 called Named Arguments and get along well with Optional Parameters.
private static void writeSomething(int a = 1, int b = 2){
// do something here;
}
static void Main()
{
writeSomething(b:3); // works pretty well
}
I was using this option to get some settings value from users.
In PHP, I cannot find anything similar except for the optional parameters but I am accepting doing $.fn.extend
(jQuery) kind of function :
function settings($options)
{
$defaults = array("name"=>"something","lastname"=>"else");
$settings = array_merge($defaults,$options);
}
settigs(array("lastname"=>"John");
I am wondering what kind of solutions you are using or you would use for the same situation.
See Question&Answers more detail:os