语法错误,PHP 中出现意外的 T_SWITCH
代码如下:
<?php
$r=rand(1,7) //get a random number from 1 to 7 inclusive...
switch($r) { //...and get a random quote
case 1:
echo '<p class="quote">welcome to Moonside.<br/>Wecomel to Soonmide.<br/>Moonwel ot Cosidme.</p>';
break;
case 2:
echo '<p class="quote">Hey! Parking Meters! And you\'re walking around!<br/>Ha ha ha... That\'s so funny.</p>';
break;
case 3:
echo '<p class="quote">"Yes" is "No" and "No" is "Yes."<br/>It makes perfect sense in Moonside.</p>';
break;
case 4:
echo '<p class="quote">Hello!<br/>And... good-bye!</p>';
break;
case 5:
echo '<p class="quote">This is a headline from tonight\'s Moonside Press...<br/>\"Mani Mani is always Mani Mani at Mani Mani with all Mani Mani Mani."</p>';
break;
case 6:
echo '<p class="quote">I can sense...that...you have a controller...in your...hands...</p>';
break;
case 7:
echo '<p class="quote">Ness\'s HP drops to 0!<br/>Jeff\'s HP drops to 0!</p>';
break;
}
?>
如果这很重要的话,我会提到整个 PHP 块在我的 HTML 源代码中缩进了两次
Here's the code:
<?php
$r=rand(1,7) //get a random number from 1 to 7 inclusive...
switch($r) { //...and get a random quote
case 1:
echo '<p class="quote">welcome to Moonside.<br/>Wecomel to Soonmide.<br/>Moonwel ot Cosidme.</p>';
break;
case 2:
echo '<p class="quote">Hey! Parking Meters! And you\'re walking around!<br/>Ha ha ha... That\'s so funny.</p>';
break;
case 3:
echo '<p class="quote">"Yes" is "No" and "No" is "Yes."<br/>It makes perfect sense in Moonside.</p>';
break;
case 4:
echo '<p class="quote">Hello!<br/>And... good-bye!</p>';
break;
case 5:
echo '<p class="quote">This is a headline from tonight\'s Moonside Press...<br/>\"Mani Mani is always Mani Mani at Mani Mani with all Mani Mani Mani."</p>';
break;
case 6:
echo '<p class="quote">I can sense...that...you have a controller...in your...hands...</p>';
break;
case 7:
echo '<p class="quote">Ness\'s HP drops to 0!<br/>Jeff\'s HP drops to 0!</p>';
break;
}
?>
If it could matter at all, I will mention that this whole PHP block is indented twice in my HTML source
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您之前忘记了分号。
You forgot a semicolon earlier.