繁体   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