echo语句php中的三元运算符

And*_*rew 13 php

我正在尝试使用tenary运算符将if else块实现到echo语句中.如果在echo语句中阻塞,我已经跟着它了.但是我不知道我的错了:

echo "<td><input type='checkbox' name='money' id='money'".(($money == 'yes')?'"checked"':" "."value='yes' /></td>";
Run Code Online (Sandbox Code Playgroud)

mel*_*okb 28

您缺少)表达式的右括号:

...(($money == 'yes')?'"checked"':" ")."value='yes' /></td>";
                                     ^ add this
Run Code Online (Sandbox Code Playgroud)

  • @Andrew:请参阅http://stackoverflow.com/questions/5680831/php-does-not-display-error-messages (2认同)