Introduction to the concrete implementation method of variable parameter list of PHP function

Source: Internet
Author: User
Tags learn php

The PHP function variable argument list can be implemented by the three functions of _get_args (), Func_num_args (), Func_get_arg (). We have described this in more detail below.

AD:2014WOT Global Software Technology Summit Beijing Station course video release

Perhaps for the PHP junior programmer, the PHP function is not fully proficient in mastering. Today we introduce to you the PHP function variable parameter list is mainly implemented using the Func_get_args (), Func_num_args (), Func_get_arg () Three system functions, wherein the Func_get_args () The function obtains a list of parameters in the form of an array, as specified in the manual.

    • Teach you to quickly implement PHP full-site permission verification
    • PHP garbage collection mechanism prevents memory overflow
    • Tips for sharing PHP performance optimizations
    • php function Isset () can only be used for variables
    • Quickly learn PHP encryption and decryption skills

The PHP function variable argument list code is as follows:

  1. < php
  2. /**
  3. * Implementation of multi-parameter list of functions
  4. *
  5. */
  6. function Multiargs ()
  7. {
  8. /** returns the list of parameters as an array */
  9. $args = Func_get_args();
  10. Number of/** parameters */
  11. $args_num = Func_num_args();
  12. foreach ($args as $key => $value)
  13. {
  14. Echo ' This is ', $key +1, ' th argument: ', $value, '<br/>';
  15. }
  16. Echo ' number of args is ', $args _num;
  17. }
  18. Multiargs (' One ', ' one ', ' one ', ' three ');
  19. /** Output */
  20. /**
  21. This is 1th Argument:one
  22. This is 2th Argument:two
  23. This is 3th argument:three
  24. Number of args is 3
  25. */
  26. ?>

The above is the implementation method of the variable parameter list of PHP function.

Introduction to the concrete implementation method of variable parameter list of PHP 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.