in Php

Null Coalescing Operator in PHP 7

Null coalescing operator (??) is introduced in PHP 7. This feature can be very useful. The Null coalescing operator will return first operand if it exists & not null, otherwise it will return its second operand.

Let’s see what is this all about :

This is what we have been doing probably. This seems alright . But using null coalescing operator  all we have to do is :

These both syntax will work.

These above code seems pretty good right ? :p The equivalent code with null coalescing operator would be :

Both will work , it’s just about preferences. You can use any method. 🙂 Happy coding