php中??和?:区别
??和?:区别:
$headerVal = 0; this->params =this−>params=headerVal ?? 2; 相当于 isset(headerVal) ?headerVal)?headerVal : 2; //结果是0 this->params =this−>params=headerVal ?: 2; 相当于 !empty(headerVal) ?headerVal)?headerVal : 2; //结果是2
??和?:区别:
$headerVal = 0; this->params =this−>params=headerVal ?? 2; 相当于 isset(headerVal) ?headerVal)?headerVal : 2; //结果是0 this->params =this−>params=headerVal ?: 2; 相当于 !empty(headerVal) ?headerVal)?headerVal : 2; //结果是2