[英]Using “named” parameters in function call
不幸的是,PHP不支持命名参数,但我注意到PHP语法允许我们进行以下操作:
function list_items( $user, $archived ) { ... }
// This is the default way to call the function.
// It's not very clear what the value and false refer to:
list_items( 10, false );
// Alternative syntax I found which makes this more clear:
list_items( $user = 10, $archived = false );
两个函数调用都返回相同的数据。
题
要回答这个问题:没有命名参数。
我问题中的示例只是将值分配给变量,然后将这些变量传递给函数。
list_items( $user = 10, $archived = false );
// is same as this:
$user = 10;
$archived = false;
list_items( $user, $archived );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.