【发布时间】:2018-08-03 21:32:03
【问题描述】:
我一直在阅读documents 并试图让一段代码工作无济于事。如果值与数据库中的值匹配,我想检查无线电输入。我正在发布相关的代码。
原if语句
if(isset($_POST['radioValue'])){
if($prospectAnswer == $script[$getScriptAA]){
echo 'checked="checked';}}
到目前为止我已经尝试过什么......
$input .= ' <input
'.((isset($_POST['radioValue'])
&& ($prospectAnswer == $script[$getScriptAA])) ? 'checked="checked').'
type="radio"
name="sAnswer"
value="'.$script[$getScriptAA].'">
<span class="radiotext"> '.$script[$getScriptAA].'</span>';
【问题讨论】:
-
您缺少“:”。如
(condition) ? checked : unchecked.
标签: php concatenation ternary-operator