Is it possible to count missing arguments in a PHP function? I want to do this:
// I have this
function foo($param1, $param2, $param3) {
// I need some sort of argument counter
}
foo("hello", "world");
When I use the foo function like above, I want a way to find out that not all arguments are used.
Either by counting all arguments and comparing to get_defined_vars(), or by using a function that gives me the count of missing arguments.
Edit:
I need the method to stop running if some of the arguments are missing when error_reporting is turned of.
if(!foo($param)) { echo "Couldn't Foo!"; }
If you want to do this super-dynamical, use reflection to get the expected parameter count and compare that number to what func_num_args() returns: