In PHP, if I have a function written like this
function example($argument1, $argument2="", $argument3="")
And I can call this function in other place like this
example($argument1)
But if I want to give some value to the thrid argument, Should I do this
example($argument1, "", "test");
Or
example($argument1, NULL, "test");
I think both will work but what is the better way? Because in future if the value for the $argument2 is changed in the main function and if I have "", then will there be any problem? Or NULL is the best option?
Thanks
You can use either:
Or
You can always check for NULL using instead of empty string:
I think it all depends on what happens inside the function with the args.