单选按钮价值困境

$instance['what_to_check_for']   = sanitize_text_field($new_instance['what_to_check_for']);

Now I a trying to do something through ternary operators →

$description_radio_box = $instance[ 'what_to_check_for' ] ? 'check_for_counter' : 'check_for_image';

basically I am trying to find a condition →

<?php if( $description_radio_box == 'check_for_counter' ){ ?>

or

                <?php if( $description_radio_box == 'check_for_image' )

Is my approach correct or I am misisng something because the two above conditions doesnt work?

related post

You don't need to add ternary operators for assign value. As your radio buttons it self containing value like check_for_counter or check_for_image. Simply assign radio button value to $description_radio_box

change

$description_radio_box = $instance[ 'what_to_check_for' ] ? 'check_for_counter' : 'check_for_image';

To

$description_radio_box = $instance[ 'what_to_check_for' ];