doubi3996
doubi3996
2018-05-28 10:00
浏览 27
已采纳

解析错误:语法错误,第10行意外'其他'(T_ELSE)[重复]

This question already has an answer here:

Can someone please give me some guidance on how to deal with this error? I'm not a programmer and so have little to no skills / knowledge about this kind of thing. But, I'm keen to learn, and would be really greatful if someone could give me some guidance.

Parse error: syntax error, unexpected 'else' (T_ELSE) on line 10

The code this relates to is below:

<?php 


include 'desciptions.php';
include 'title.php';
$rand=rand(0,67);


else if($rand=='1')
    $desciptions=$d1;
    $title=$m1;

else if($rand=='2')
    $desciptions=$d2;
    $title=$m2;

else if($rand=='0')
    $desciptions=$d0;
        $title=$m0;
?>
</div>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douzheng5717
    douzheng5717 2018-05-28 10:06
    已采纳

    Remove the first else, add { and } and remove the ticks:

    <?php 
    
    include 'desciptions.php';
    include 'title.php';
    $rand=rand(0,67);
    
    if($rand == 1) {
        $desciptions = $d1;
        $title = $m1;
    } else if($rand == 2) {
        $desciptions = $d2;
        $title = $m2;
    } else if($rand == 0) {
        $desciptions = $d0;
        $title = $m0;
    }
    ?>
    

    Also maybe fix desciptions to descriptions.

    点赞 评论
  • douchuopiao9002
    douchuopiao9002 2018-05-28 10:05

    Change your code to this:

    <?php
    
    include 'desciptions.php';
    include 'title.php';
    $rand = rand(0, 67);
    
    
    if ($rand == '1') {
        $desciptions = $d1;
        $title = $m1;
    } elseif ($rand == '2') {
        $desciptions = $d2;
        $title = $m2;
    } elseif ($rand == '0') {
        $desciptions = $d0;
        $title = $m0;
    }
    ?>
    
    点赞 评论

相关推荐