We have answer of your question!

100% solved queries, no empty question

Question: How to make function arguments options?


0

Advertisement


If you have a function like so:

function somefunc ($data, $something) {
//
}

When you call the function like this:

somefunc($data);

it sends error saying it is missing argument 2. Is there a way to make the second argument optional? Thanks

Question author User2413333 | Source

Answer


1


Advertisement


Try

function somefunc ($data, $something = null) {
//
}
Answer author Pudge601

Advertisement


Tickanswer.com is providing the only single recommended solution of the question How to make function arguments options? under the categories i.e php , function , parameters , . Our team of experts filter the best solution for you.

Related Search Queries:

function arguments c++ ,

You may also add your answer!