0

This is normal radio button

<?php
$che='adi';
$che1='adi';
?>

<input type="radio" name="Owner" <?php if($che==$che1) {echo "checked";}?> value="A">A

I want this php code in under echo for checked

<?php
$che='adi';
$che1='adi';

echo'<input type=radio name=ans  value=A>A';?>

1 Answers1

0

Try :

echo'<input type=radio name=ans '.(($che == $che1)? "checked" : "").' value=A>A';

Reference :https://davidwalsh.name/php-ternary-examples

Illya
  • 1,268
  • 1
  • 5
  • 16