- 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.
推薦閱讀
- 零基礎搭建量化投資系統:以Python為工具
- 編寫高質量代碼:改善Python程序的91個建議
- 程序員考試案例梳理、真題透解與強化訓練
- Python Tools for Visual Studio
- 新手學Visual C# 2008程序設計
- Designing Hyper-V Solutions
- 從0到1:Python數據分析
- Scala Reactive Programming
- iPhone應用開發從入門到精通
- Creating Data Stories with Tableau Public
- R語言數據挖掘:實用項目解析
- 和孩子一起學編程:用Scratch玩Minecraft我的世界
- 軟硬件綜合系統軟件需求建模及可靠性綜合試驗、分析、評價技術
- 信息學奧林匹克競賽初賽精講精練
- PhantomJS Cookbook