php
PHP trymeout 5d ago 100%

Should I create functions for packages/libraries that allow optional parameters to accept null as a value?

Should I create functions for packages/libraries that allow optional parameters to accept null?

In this example below, I set the 3rd and 4th parameter as null which will act as the default value.

myLibrary::myFunction(1, 7, null, null, true);

Or is this not a good way to go about creating functions for a package and therefore should not accept null as a parameter value.

myLibrary::myFunction(1, 7, false, 4, true);

12
1
Comments 1