簡體   English   中英

是否有諸如Null合並運算符之類的稱為空合並運算符的東西

[英]Is there something called empty coalescing operator like Null coalescing operator

PHP 7添加了null合並運算符

// Fetches the value of $_GET['number'] and returns 'nonumber -NULL'
// if it does not exist.
$username = $_GET['number'] ?? 'No Number';
// This is equivalent to:
$username = isset($_GET['number']) ? $_GET['number'] : 'No Number';

還有空的東西嗎?

尋找類似的東西,

/ Fetches the value of $_GET['number'] and returns '0' Empty
// if it does not empty.
$username = $_GET['number'] ?? 'no number or number is 0 or empty';

是的,感謝短三元運算符類型的強制類型?:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM