- Building RESTful Web Services with PHP 7
- Haafiz Waheed ud din Ahmad
- 72字
- 2021-07-03 00:02:22
Null coalescing operator
The Null coalescing operator (??) is a syntactical sugar, but a very important one. Previously in PHP5 when we were having some variable which could be undefined, we used the ternary operator as follows:
$username = isset($_GET['username']) ? $_GET['username'] : '';
However, now in PHP7, we can simply write:
$username = $_GET['username'] ?? '';
Although this is just a syntactical sugar, it can save time and make code cleaner.
推薦閱讀
- Boost程序庫完全開發指南:深入C++”準”標準庫(第5版)
- Spring 5.0 By Example
- Java面向對象思想與程序設計
- 控糖控脂健康餐
- 程序員面試算法寶典
- Java加密與解密的藝術
- Kali Linux Wireless Penetration Testing Beginner's Guide(Third Edition)
- Python面向對象編程:構建游戲和GUI
- Oracle從入門到精通(第5版)
- Java Web從入門到精通(第2版)
- Backbone.js Testing
- C#面向對象程序設計(第2版)
- 現代CPU性能分析與優化
- Python面試通關寶典
- Oracle Database XE 11gR2 Jump Start Guide