PHP Extracurricular notes--implementation of variable parameter list of function

Source: Internet
Author: User

PHP Extracurricular notes--implementation of variable parameter list of function PHP is very powerful in terms of functions, but for some novice PHP, understanding is part of the difficulty, not fully mastered.
In the PHP training tutorial, we introduce the implementation of a variable parameter list of functions:

The implementation of the variable parameter list of PHP functions is mainly implemented by using the three system functions of Func_get_args (), Func_num_args (), Func_get_arg (), where the Func_get_args () function obtains the parameter list in the form of an array , refer to the manual for specific usage.

The PHP function variable argument list code is as follows:

< PHP
/* Implementation of the multi-parameter list of functions */
function Multiargs ()
{
/** returns the list of parameters as an array */
$args = Func_get_args ();
Number of/** parameters */
$args _num = Func_num_args ();
foreach ($args as $key = $value)
{
Echo ' This is ', $key +1, ' th argument: ', $value, ' <br/> ';
}
Echo ' number of args is ', $args _num;
}
Multiargs (' One ', ' one ', ' one ', ' three ');
/** Output */
/**
This is 1th Argument:one
This is 2th Argument:two
This is 3th argument:three
Number of args is 3
*/
?> (Hefei Open Source It education example code)
The above is the implementation method of the variable parameter list of PHP function


This article comes from: PHP training, open source it education, open source it education and training

PHP Extracurricular notes--implementation of variable parameter list of function

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.