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

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.

主站蜘蛛池模板: 泸定县| 大化| 乡城县| 大新县| 榆树市| 巨野县| 自治县| 新沂市| 那坡县| 尼木县| 油尖旺区| 绥滨县| 九江县| 通许县| 东台市| 奉贤区| 二连浩特市| 阳西县| 民勤县| 甘肃省| 乐山市| 上饶县| 双江| 同心县| 吴堡县| 昌乐县| 峡江县| 榆社县| 正安县| 博爱县| 大渡口区| 蒙城县| 星座| 那坡县| 新晃| 古蔺县| 阿拉善左旗| 南华县| 普陀区| 佛坪县| 滨海县|