语法错误,PHP 中出现意外的 T_SWITCH

发布于 12-26 01:14 字数 1234 浏览 1 评论 0原文

代码如下:

<?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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戒ㄋ2025-01-02 01:14:07

您之前忘记了分号。

You forgot a semicolon earlier.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文