1<?php
2$v = 1;
3
4$r = (1 == $v) ? 'Yes' : 'No'; // $r is set to 'Yes'
5$r = (3 == $v) ? 'Yes' : 'No'; // $r is set to 'No'
6
7echo (1 == $v) ? 'Yes' : 'No'; // 'Yes' will be printed
8
9// and since PHP 5.3
10$v = 'My Value';
11$r = ($v) ?: 'No Value'; // $r is set to 'My Value' because $v is evaluated to TRUE
12
13$v = '';
14echo ($v) ?: 'No Value'; // 'No Value' will be printed because $v is evaluated to FALSE
15?>
16