YouTip LogoYouTip

Php Coalescing Operator

# PHP NULL Coalescing Operator [![Image 3: PHP 7 New Features](#) PHP 7 New Features](#) The NULL coalescing operator (??) added in PHP 7 is a shorthand for the ternary operation that performs an isset() check. The NULL coalescing operator checks if a variable exists and its value is not NULL. If so, it returns its value; otherwise, it returns its second operand. Previously, we wrote the ternary operator like this: $site = isset($_GET['site']) ? $_GET['site'] : ''; Now we can write it directly like this: $site = $_GET['site'] ?? ''; ### Example The output of the above program execution is: * * PHP 7 New Features](#)
← Php Coalescing OperatorHtml5 Websocket β†’