[英]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.