Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

null coalescing operator example in php

$name = $_GET['name'] ?? $_POST['name'] ?? 'nobody';
//it is equavelent to below conditions

if (isset($_GET['name'])) {
 $name = $_GET['name'];
} elseif (isset($_POST['name'])) {
 $name = $_POST['name'];
} else {
 $name = 'nobody';
}
 
PREVIOUS NEXT
Tagged: #null #coalescing #operator #php
ADD COMMENT
Topic
Name
2+3 =