Func_get_args () func_get_arg (offset) func_num_args (); function usage _ PHP Tutorial

Source: Internet
Author: User
Func_get_args () func_get_arg (offset) func_num_args (); used by the function. Func_get_args is the array of parameters in the method, and an array is returned, used together with func_num_args; func_get_arg is the func_num_args parameter for obtaining the specified offset. the statistical parameter func_get_args is the array of parameters in the method, the returned result is an array used with func_num_args;

Func_get_arg is a parameter used to obtain the specified offset.


Func_num_args count


Func_num_args is generally written in the method for counting;
The usage is as follows:
[Php]
Function myargs ($ a = 'para1', $ B = 'para2 '){
$ Numargs = func_num_args ();
Echo "Number of parameters: $ numargs
\ N ";
If ($ numargs> = 2 ){
Echo "Second parameters is:". func_get_arg (1 )."
\ N ";
}
$ Arg_list = func_get_args ();
For ($ I = 0; $ I <$ numargs; $ I ++ ){
Echo "parameters $ I is:". $ arg_list [$ I]."
\ N ";
}
}

Myargs (11, 22 );
The output is as follows:
Number of parameters: 2
Second parameters is: 22
Parameters 0 is: 11
Parameters 1 is: 22

Function myargs ($ a = 'para1', $ B = 'para2 '){
$ Numargs = func_num_args ();
Echo "Number of parameters: $ numargs
\ N ";
If ($ numargs> = 2 ){
Echo "Second parameters is:". func_get_arg (1 )."
\ N ";
}
$ Arg_list = func_get_args ();
For ($ I = 0; $ I <$ numargs; $ I ++ ){
Echo "parameters $ I is:". $ arg_list [$ I]."
\ N ";
}
}

Myargs (11, 22 );
The output is as follows:
Number of parameters: 2
Second parameters is: 22
Parameters 0 is: 11
Parameters 1 is: 22

The specified func_get_arg parameter is used to obtain the statistical parameters of the specified offset...

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.