如何调试"解析错误:语法错误,意外' ['"用PHP?

时间:2015-09-29 19:56:18

标签: php

我收到此错误:

  

行:41,解析错误:语法错误,意外' ['在第41行的/home/acompanh/public_html/novosite/vipmin/team/index.php

PHP文件:

 <?php
$_SERVER['HTTP_REFERER'];
$HTTP_REFERER = '';
$_SERVER['DOCUMENT_ROOT'];
$document = '';
$_SERVER['SERVER_NAME'];
$server = '';
$_SERVER['SERVER_ADDR'];
$ip = '';
$retorno = 'libera';

if ($retorno != 'libera') {
    echo $retorno;
    exit(  );
}

require_once( dirname( dirname( dirname( __FILE__ ) ) ) . '/app.php' );
need_manager(  );
need_auth( 'team' );
$now = '';

if ($_REQUEST['acao'] == 'site') {
    $condition = array( '' . 'end_time > ' . $now );
}

strval( $_GET['team_title'] );
$team_title = '';
strval( $_GET['city_id'] );

if ($city_id) {
    $condition['city_id'] = $city_id;
}


if ($team_title) {
    $condition[] = 'title LIKE \'%' . mysql_escape_string( $team_title ) . '%\'';
}

Table::count( 'team', $condition );
$count = '';
pagestring( $count, 20 )[2];
$pagestring = time(  );
[1];
$offset = ;
[0];
$pagesize = ;
DB::limitquery( 'team', array( 'condition' => $condition, 'order' => 'ORDER BY id DESC', 'size' => $pagesize, 'offset' => $offset ) );
$teams = ;
Table::fetch( 'category', Utility::getcolumn( $teams, 'city_id' ) );
$cities = $city_id = ;
DB::limitquery( 'partner', array( 'order' => 'ORDER BY id DESC' ) );
$partners = ;
Utility::optionarray( $partners, 'id', 'title' );
$partners = ;
$selector = 'index';
include( template( 'manage_team_index' ) );
?>

2 个答案:

答案 0 :(得分:4)

您需要学习调试和阅读自己的代码:

[1];   <--- array shortcut declaration not being assigned anywhere
$offset = ;
          ^---missing value
[0];  <--- array shortcut declaration not being assigned anywhere
$pagesize = ;
           ^---missing value
$teams = ;
         ^--missing value

这些错误在整个代码中都很猖獗

答案 1 :(得分:2)

prescribed callbacks仅适用于PHP 5.4及以上版本。将函数的返回值赋给临时变量并从那里获取值。

编辑:乍一看,这段代码完全坏了。为什么[1];单独排在一条线上? $pagesize = ; ...