- 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 C++數字圖像模式識別技術詳解
- Hands-On C++ Game Animation Programming
- PhpStorm Cookbook
- 51單片機C語言開發教程
- Access 2010數據庫應用技術實驗指導與習題選解(第2版)
- Unity Character Animation with Mecanim
- Python計算機視覺和自然語言處理
- Android移動應用項目化教程
- C語言程序設計
- Deep Learning for Natural Language Processing
- 從“1”開始3D編程
- Monitoring Docker
- Spring Boot從入門到實戰
- Java與Android移動應用開發:技術、方法與實踐