Php Basics: function parameters-php Tutorial

Source: Internet
Author: User
Tags php basics php compiler
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.