1.2.155. Coalesce

Usage of coalesce operator.

Note that the coalesce operator is a special case of the ternary operator.

<?php

// Coalesce operator, since PHP 5.3
$a = $b ?: 'default value';

// Equivalent to $a = $b ? $b : 'default value';

?>

See also Ternary Operator.

1.2.155.1. Specs

Short name

Php/Coalesce

Rulesets

All, Appinfo, CE, Changed Behavior, One Liners

Exakat since

0.8.4

PHP Version

With PHP 5.3 and more recent

Severity

Time To Fix

Precision

Very high

Features

closure, $this

Available in

Entreprise Edition, Community Edition, Exakat Cloud