PHP ternary function with an IF and OR statement -


can use ternary function replace code?

if (isset($_post['something']) || ($_post['something']=="")){     $a= "n/a"; else{     $a= $_post['something']; } 

i trying it's not working...

$a = (isset($_post['something']) || ($_post['something']=="")) ? $_post['something'] : 'n/a'; 

i sending form field can empty , want replace n/a or 'no aplica' spanish when user leave field blank.

this should it.

$a = (!empty($_post['something'])) ? $_post['something'] : 'n/a'; 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -