if echo

$value = 'aaa';
 echo $value=='aaa' ? 'yes' : 'no';

example 1

echo "always say this " . ( ($test == "true") ? 
"Say this if that is true" : "") . " Always say this at the end.";

example 2

echo '<option value="'.$value.'"'.($value=='United States' ? 
'selected="selected"' : '').'>'.$value.'</option>';

Leave a Reply