Func_get_args () Func_get_arg (offset) Func_num_args (); function Use _php Tutorial

Source: Internet
Author: User
Func_get_args is an array that gets the arguments in the method, and returns an array that is used in conjunction with the Func_num_args;

Func_get_arg is the parameter that gets the specified offset


Func_num_args Number of statistical parameters


Func_num_args is generally written in the method for counting;
Here's how to use it:
[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 will be:
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 will be:
Number of Parameters:2
Second Parameters is:22
Parameters 0 Is:11
Parameters 1 is:22

http://www.bkjia.com/PHPjc/477547.html www.bkjia.com true http://www.bkjia.com/PHPjc/477547.html techarticle Func_get_args is an array that gets the arguments in the method, returns an array that is used with the Func_num_args, Func_get_arg is the parameter that gets the specified offset Func_num_args the number of statistical parameters ...

  • 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.