0

Suppose I have a function defined as following :

public function test($title, $body, $role = 0, $place = 0)
{
    //do something
}

so, when i call the function like this :

test('myname', 'sometext', third_arg);

I want 'third_arg' to be the argument for $place and no argument for $role.
I also don't know which of the $role or $place will have a value passed when the function is called everytime.
How do I pass the argument for $place ? Thanks in advance!

2 Answers 2

2

Pass 0 OR null in 3rd argument:

test('myname', 'sometext', 0 ,third_arg);

OR

test('myname', 'sometext', '' ,third_arg);
Sign up to request clarification or add additional context in comments.

2 Comments

better to send 0 instead of empty string. Since the default value is set to 0
.. Or you can also use the boolean false
0

As the default value for third argument is 0 just pass the value 0 to the third. e.g: test('myname', 'sometext', 0,third_arg) ;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.