PHP Ternary Operator not working for this code -


i use ternary operator below code..

<?php  if($users['active'] == 1 )  {      echo 'yes';  }  else  {      echo 'no';  }  ?> 

i tried using code , not work..

<?php ($users['active'] == 1) ? echo "yes" : echo "no";  ?> 

what wrong?

the echo goes outside of it, not in, (the ternary operator) returning value, not codeblock.

<?php echo ($users['active'] == 1 ? "yes" : "no"); ?> 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -