1// The null coalescing operator (??) is used to replace the ternary operation
2// in conjunction with isset() function and returns its first operand if it
3// exists and is NOT NULL; otherwise it returns its second operand.
4$username = $_GET['username'] ?? 'not passed';
5
6// Equivalent code using ternary operator
7$username = isset($_GET['username']) ? $_GET['username'] : 'not passed';
1// if $_POST['name'] doesn't exist $result will equal to John
2$result = $_POST['name'] ?? 'John';