Php Basics: function parameters
Function run () {echo 123 ;}$ _ a = 'a'; $ _ B = 'BB'; run ($ _ a, $ _ B ); // Row 3. when a function is defined, the parameter is null. // When row 3 is called, no error will be reported if any variable is input in the parameter, why? // Is my infrastructure too poor?
Reply to discussion (solution)
Should there be a warning or error prompt when the parameters in the definition are inconsistent with those in the call?
The number of parameters should not be less than the number of parameters without default values in the definition.
Because PHP supports variable parameter lists in user-defined functions.
You can use the func_num_args (), func_get_arg (), and func_get_args () functions to call parameters.
Should there be a warning or error prompt when the parameters in the definition are inconsistent with those in the call?
Don't take it for granted. you can check the manual or something uncertain, or write your own code for testing. practice is a good way to test the truth.
No error is reported when the provided parameters are more than the ones specified by the function.
Php compiler to improve encoding flexibility
If you want to learn more... look at the php source code, or even the subroutine implementation of the assembly language