Home > Backend Development > PHP Tutorial > 函数的实参可以多于形参,这有什么用?

函数的实参可以多于形参,这有什么用?

WBOY
Release: 2016-06-20 12:48:12
Original
1332 people have browsed it

function test($date, $value) {    echo "$date $value";}$date = "9月18号";$value = "100";$y = "2";test($date, $value, false);
Copy after login

函数的实参可以多于形参,这有什么用?


回复讨论(解决方案)

对于你的设计,多的没有用!

对于你的设计,多的没有用!


在官网查不到这样的案例,这个有设计案例吗?

好像并没有什么卵用

好像并没有什么卵用



这里不清楚他这样设计是什么意思?

给一个实参多于形参的设计

function mul($a) {  $b = func_num_args() > 1 ? func_get_arg(1) : $a;  return $a * $b; }echo mul(2); //4echo mul(2, 3); //6
Copy after login

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template