書名: 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.
推薦閱讀
- 新編Visual Basic程序設計上機實驗教程
- Java范例大全
- 深入淺出Spring Boot 2.x
- Mastering Python High Performance
- 高級C/C++編譯技術(典藏版)
- Learning ArcGIS Pro
- Java編程技術與項目實戰(第2版)
- JavaCAPS基礎、應用與案例
- C語言程序設計與應用(第2版)
- 深度實踐KVM:核心技術、管理運維、性能優化與項目實施
- TypeScript圖形渲染實戰:2D架構設計與實現
- Python物理建模初學者指南(第2版)
- 安卓工程師教你玩轉Android
- Illustrator CS6中文版應用教程(第二版)
- BackTrack 5 Cookbook