Func_get_args () func_get_arg (offset) func_num_args (); function usage

Source: Internet
Author: User

Func_get_args is the array for obtaining parameters in the method. It returns 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 <br/> \ n ";
If ($ numargs> = 2 ){
Echo "Second parameters is:". func_get_arg (1). "<br/> \ n ";
}
$ Arg_list = func_get_args ();
For ($ I = 0; $ I <$ numargs; $ I ++ ){
Echo "parameters $ I is:". $ arg_list [$ I]. "<br/> \ 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 <br/> \ n ";
If ($ numargs> = 2 ){
Echo "Second parameters is:". func_get_arg (1). "<br/> \ n ";
}
$ Arg_list = func_get_args ();
For ($ I = 0; $ I <$ numargs; $ I ++ ){
Echo "parameters $ I is:". $ arg_list [$ I]. "<br/> \ 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

 

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.