Welcome Guest, Not a member yet? Register   Sign In
variable function argument amount
#1

[eluser]plainas[/eluser]
I would like to have a function that would accept sometimes one argument sometimes two.
But whenever i call it with only one argument it throws a php error.

Basically I want both of this to be possible:

mysite.com/index.php/controller/function/arg

mysite.com/index.php/controller/function/arg/another_arg

EDIT: ok, that problem is easily solvable by assigning a default value to optional parameters.
Mods please delete this topic
#2

[eluser]Derek Allard[/eluser]
I'm glad you got the solution! I'm going to leave it here in case others are looking for this same topic (with your permission. If you still want me to remove it I will).
#3

[eluser]plainas[/eluser]
No problem.
Leave it in here.




Theme © iAndrew 2016 - Forum software by © MyBB