Ternary operator in Laravel 5


Just today, I was looking at using a ternary operator in Laravel’s Blade templating system.

However, instead of writing a ternary statement, Blade provides you with the following convenient short-cut:

{{ $string or 'something' }}

In this example, if the $string variable exists, its value will be displayed. However, if it does not exist, the word something will be displayed.