cyphix
03-03-2008, 09:19 PM
Hey guys.... kind of a dumb question, been coding PHP for over 3 years now & for some reason never come across finding out what these mean....
See the below code..
$bla = isset($_POST['blah']) ? $_POST['blah'] : false;
echo '<select name="blah">';
echo '<option value="opt_1" '. $bla == 'opt_1' ? 'selected="selected"' : '' .'>1</option>';
echo '<option value="opt_2" '. $bla == 'opt_2' ? 'selected="selected"' : '' .'>2</option>';
echo '<option value="opt_3" '. $bla == 'opt_3' ? 'selected="selected"' : '' .'>3</option>';
echo '</select>';
What exactly is the use of the '?' & ':' in the above code?
Thanks guys! :thumbsup:
See the below code..
$bla = isset($_POST['blah']) ? $_POST['blah'] : false;
echo '<select name="blah">';
echo '<option value="opt_1" '. $bla == 'opt_1' ? 'selected="selected"' : '' .'>1</option>';
echo '<option value="opt_2" '. $bla == 'opt_2' ? 'selected="selected"' : '' .'>2</option>';
echo '<option value="opt_3" '. $bla == 'opt_3' ? 'selected="selected"' : '' .'>3</option>';
echo '</select>';
What exactly is the use of the '?' & ':' in the above code?
Thanks guys! :thumbsup: