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

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.

主站蜘蛛池模板: 汨罗市| 山西省| 板桥市| 济宁市| 翁牛特旗| 苍梧县| 田东县| 出国| 石景山区| 罗田县| 米林县| 德州市| 买车| 九江县| 治县。| 微山县| 锦州市| 元朗区| 东丽区| 高尔夫| 四川省| 封丘县| 临城县| 临沧市| 南陵县| 澄城县| 蒲城县| 密山市| 丹江口市| 武川县| 德州市| 江北区| 岐山县| 苏州市| 潜江市| 柯坪县| 内黄县| 延长县| 西丰县| 福州市| 都安|