Home  >  Article  >  Backend Development  >  请写一个php函数,接受任意数量的参数,该怎么解决

请写一个php函数,接受任意数量的参数,该怎么解决

WBOY
WBOYOriginal
2016-06-13 10:15:12792browse

请写一个php函数,接受任意数量的参数
这是一道面试题。

怎么写这个函数呢?  

function fun(......)
{


}

------解决方案--------------------
这些不都是很基础的东西么?

PHP code
show_params(1, 2, 'apple', 3.14);function show_params () {    //获取传递参数的个数    $count = func_num_args();    //遍历参数并逐一输出    for ($i = 0; $i <font color="#e78608">------解决方案--------------------</font><br>
PHP code
function func(){    var_dump(func_get_args());}<div class="clear">
                 
              
              
        
            </div>
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