Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PHP always support passing more arguments than the method expected?

Tags:

php

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?

like image 684
user6670476 Avatar asked Sep 02 '16 11:09

user6670476


People also ask

How many arguments can a PHP function have?

PHP native functions According to the manual, PHP functions may accept up to 12 arguments.

Does PHP support variable length 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.

How many arguments can a method call have?

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.

What is default argument in PHP precedence?

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.


1 Answers

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).

like image 146
Daniel Avatar answered Oct 17 '22 16:10

Daniel