我不明白为什么我的按钮中的第二个值没有完全显示
<p><input type ="button" id="comment"
value=<?php echo $comment_exist == null ? 'Save' : 'Cancel my comment'; ?>></p>
如果条件为真,则显示Save
如果不是Cancel
,则显示not my comment
。
答案 0 :(得分:2)
你需要引用你的价值观。无论是单引号还是双引号。并始终有关闭“自我关闭”标签的做法/>
<p>
<input type ="button" id="comment"
value="<?php echo $comment_exist == null ? 'Save' : 'Cancel my comment'; ?>" />
</p>
答案 1 :(得分:0)
试试这个(添加引号)
<p><input type ="button" id="comment"
value="<?php echo $comment_exist == null ? 'Save' : 'Cancel my comment'; ?>"></p>
答案 2 :(得分:0)
尝试引用这个PHP代码,这可能会起作用
<p><input type ="button" id="comment" value="<?php echo $comment_exist == null ? 'Save' : 'Cancel my comment'; ?>"></p>