这是我的代码,我明白重要的是不要在同一行上混合使用html和php,但我无法理解这一点!有人可以帮忙吗?我尝试了一些替代方案,但我一直得到意外的语法错误'}'。
<?php //Creating random number s
$rid = rand(1,3);
echo $rid; if ($rid == 1){ ?>
<form action="<?php echo base_url(); ?>index.php/welcome/result" method='post' id='quizForm' id='1'>
<input type="hidden" name="id" value="1"/>
<ol>
<li>
<h3>What does PHP stand for?</h3>
<div>
<input type='radio' name='answerOne' id='answerOne' value='A' />
<label for='answerOneA'>A) Hyper text markup language</label>
</div>
<div>
<input type='radio' name='answerOne' id='answerOne' value='B' />
<label for='answerOneB'>B) PHP: Preprocessed hypertext</label>
</div>
<div>
<input type='radio' name='answerOne' id='answerOne' value='C' />
<label for='answerOneC'>C) PHP: Hypertext Preprocessor</label>
</div>
</li>
<li>
<h3>Who invented PHP?</h3>
<div>
<input type='radio' name='answerTwo' id='answerTwo' value='A' />
<label for='answerTwoA'>A) Dick Dastardly </label>
</div>
<div>
<input type='radio' name='answerTwo' id='answerTwo' value='B' />
<label for='answerTwoB'>B) Rasmus Lerdof</label>
</div>
<div>
<input type='radio' name='answerTwo' id='answerTwo' value='C' />
<label for='answerTwoC'>C) God</label>
</div>
</li>
<li>
<h3>What is PHP used for?</h3>
<div>
<input type='radio' name='answerThree' id='answerThree' value='A' />
<label for='answerThreeA'>A) Creating dynamic webpages</label>
</div>
<div>
<input type='radio' name='answerThree' id='answerThree' value='B' />
<label for='answerThreeB'>B) Server-side scripting</label>
</div>
<div>
<input type='radio' name='answerThree' id='answerThree' value='C' />
<label for='answerThreeC'>C) All of the above</label>
</div>
</li>
</ol>
<input type='submit' value='Submit Answers' />
</form>
<?php
}
?>