Actually, it would be more like:
<?php
function printSelected($current_value, $value) {
if ($current_value == $value)
return ' selected="selected"';
}
?>
<select name="State">
<option value="Perlis"<? echo printSelected('Perlis', State); ?>>Perlis</option>
<option value="Selangor"<? echo printSelected('Selangor', $State); ?>>Selangor</option>
<option value="Sabah"<? echo printSelected('Sabah', $State); ?>>Sabah</option>
<option value="Sarawak"<? echo printSelected('Sarawak', $State); ?>>Sarawak</option>
</select>
Of course there might be better methods, but it depends on the circumstances.