I have tried on PhpFiddle and the PHP version on PhpFiddle supports passing more arguments than the method expected without giving any error, but not vice versa.
In my project some of my clients' server PHP version is quite old, so I would to assure that is this behavior always supported in all versions of PHP?
PHP native functions According to the manual, PHP functions may accept up to 12 arguments.
PHP supports variable length argument function. It means you can pass 0, 1 or n number of arguments in function. To do so, you need to use 3 ellipses (dots) before the argument name. The 3 dot concept is implemented for variable length argument since PHP 5.6.
Except for functions with variable-length argument lists, the number of arguments in a function call must be the same as the number of parameters in the function definition. This number can be zero. The maximum number of arguments (and corresponding parameters) is 253 for a single function.
The default arguments must be constant expressions. They cannot be variables or function calls. PHP allows you to use a scalar value, an array, and null as the default arguments.
When passing too many arguments to a user defined function, PHP doesn't crash.
This has previously been reported as a bug, but with the current status: WONTFIX (a problem that won't be fixed).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With