官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 江永县| 班戈县| 恭城| 龙游县| 宝山区| 图木舒克市| 隆德县| 织金县| 泰宁县| 东乌珠穆沁旗| 正定县| 平安县| 桐城市| 石林| 巴林右旗| 岳普湖县| 山东省| 安顺市| 江源县| 屯昌县| 堆龙德庆县| 中方县| 新兴县| 随州市| 江达县| 玛沁县| 萨迦县| 大名县| 万安县| 教育| 仙游县| 剑川县| 左贡县| 蒲城县| 高碑店市| 仙居县| 莲花县| 深圳市| 浦城县| 双江| 金秀|