Make Parameter Optional
-
- Posts: 165
- Joined: Fri May 06, 2011 5:02 pm
Make Parameter Optional
How do I make a function parameter optional?
Re: Make Parameter Optional
Give it a default value in the definition
function I_am_a_function($first, $second = true){ // things }if no value is given for the second parameter, the code inside the function will see it as true.
-
- Posts: 165
- Joined: Fri May 06, 2011 5:02 pm
Re: Make Parameter Optional
I assume I can set = nulljacek wrote:Give it a default value in the definition
function I_am_a_function($first, $second = true){ // things }if no value is given for the second parameter, the code inside the function will see it as true.
-
- Posts: 165
- Joined: Fri May 06, 2011 5:02 pm
Re: Make Parameter Optional
yay... you can
Re: Make Parameter Optional
unemployment wrote:yay... you can
I think you can set = pretty much anything.