首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >分析错误:语法错误,第10行出现意外的'else‘(T_ELSE)

分析错误:语法错误,第10行出现意外的'else‘(T_ELSE)
EN

Stack Overflow用户
提问于 2018-05-28 18:00:41
回答 2查看 69关注 0票数 -4

有人能给我一些关于如何处理这个错误的指导吗?我不是程序员,所以对这类事情几乎没有技能/知识。但是,我热衷于学习,如果有人能给我一些指导,那就太好了。

代码语言:javascript
运行
复制
Parse error: syntax error, unexpected 'else' (T_ELSE) on line 10

与此相关的代码如下:

代码语言:javascript
运行
复制
<?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;
?>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-05-28 18:06:19

删除第一个else,添加{},然后删除勾号:

代码语言:javascript
运行
复制
<?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;
}
?>

也可以将desciptions修复为descriptions

票数 0
EN

Stack Overflow用户

发布于 2018-05-28 18:05:32

将您的代码更改为:

代码语言:javascript
运行
复制
<?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;
}
?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50563767

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档