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

WBOY
Release: 2016-06-13 10:15:12
Original
746 people have browsed it

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

怎么写这个函数呢?

function fun(......)
{


}

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

PHP code
show_params(1, 2, 'apple', 3.14);function show_params () {    //获取传递参数的个数    $count = func_num_args();    //遍历参数并逐一输出    for ($i = 0; $i ------解决方案--------------------
Copy after login
PHP code
function func(){ var_dump(func_get_args());}
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!