Home  >  Article  >  Backend Development  >  How to get function parameters in php

How to get function parameters in php

王林
王林Original
2020-07-31 14:07:464630browse

How to obtain function parameters in php: You can obtain them through the func_get_args() function. The function syntax is: [func_get_args(void)]. The array_get_args() function can obtain an array of function parameter lists.

How to get function parameters in php

func_get_args() Function: Get an array of function parameter lists.

(Recommended tutorial: php graphic tutorial)

Function syntax:

array func_get_args  ( void )

Code implementation:

<?php
function demo ()
{
  $args = func_get_args();
  echo "传入的参数分别为:";
  var_dump($args);
}
demo ( &#39;a&#39; , &#39;b&#39; , &#39;c&#39; );

(Video tutorial recommendation: php video tutorial)

Run result:

传入的参数分别为:
array (size=3)  
0 => string &#39;a&#39; (length=1)  
1 => string &#39;b&#39; (length=1)  
2 => string &#39;c&#39; (length=1)

The above is the detailed content of How to get function parameters in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn