PHP external function parameter count _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHP obtains the number of function parameters externally. FunctionWar ($ a, $ B, $ c) {$ nfunc_num_args (); echo $ n;} War (1, 2, 3); func_num_args () this function can only obtain the number of parameters in the function, but cannot be obtained outside the function. what is the function War ($ a, $ B, $ c) method)

{

$ N = func_num_args ();

Echo $ n;

}

War (1, 2, 3 );

Func_num_args (): This function can only obtain the number of parameters in the function, but cannot be obtained outside the function. Is there any way to obtain the number of function parameters externally?

--------------------------------------------------------------------------------
Func_num_args () returns the number of parameters passed to the host function.

--------------------------------------------------------------------------------
Func_num_args () gets the number of actually passed parameters, rather than the predefined number, so there should be no "external get" statement.
PHP code

Function War ()

{

$ N = func_num_args ();

Echo $ n;

}

War (1, 2, 3 );

War (1, 2, 3, 4 );

War (1, 2 );
--------------------------------------------------------------------------------
We can use comments of User-defined functions and reflection to obtain the value from "external retrieval ".

PHP code
/**
* A user-defined function
*
* @ Param string $
* @ Param string $ B
* @ Param string $ c
*/
Function War ($ a, $ B, $ c ){}

/**
* A user-defined function 2
*
* @ Param s ......

Http://www.bkjia.com/PHPjc/371715.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/371715.htmlTechArticlefunction War ($ a, $ B, $ c) {$ n = func_num_args (); echo $ n;} War (, 3); func_num_args () this function can only obtain the number of parameters in the function, but cannot be obtained outside the function. what is the method...

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.