
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Double Question Mark Operator in PHP
PHP 7 has added a new operator double question mark (??) operator. In PHP 7, the double question mark(??) operator known as Null Coalescing Operator.
It returns its first operand if it exists and is not NULL; otherwise, it returns its second operand. It evaluates from left to right. Null Coalescing operator also can be used in a chain format.
Let's take the below example to demonstrate the double question mark (??) operator.
Example
<?php //$a is not set echo $a ?? 9 ??45; ?>
Output
9
Example
<?php //$a is not set $b = 34; echo $a ?? $b ?? 7; ?>
Output
34
Advertisements