2014-12-30 07:41 阅读 137


I was trying to move my website to my new server. But after I moved the code and wanted to run the website, I got this php error:

PHP Parse error:  syntax error, unexpected ''] = "'' (T_CONSTANT_ENCAPSED_STRING), expecting ']' in /home/mywebsite/public_html/includes/functions/functions_general.php on line 1230

Here is the code on line 1230:

$trans_table['''] = "'";

The strange thing is that this error was never reported on my old server. Could someone help?

Thank you.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • 已采纳
    douse8732 douse8732 2014-12-30 07:47

    This is one of most common parsing PHP errors, I have encountered it mostly due to version conflict.

    The PHP version on new server may be different from old one. Most probably lower than old one. Upgrade/ Match PHP version on both servers to get rid of error.

    点赞 评论 复制链接分享
  • douzuanze0486 douzuanze0486 2014-12-30 07:44

    There are three single quotes characters inside the [], you should use double quotes for array index, instead of single quotes.

    点赞 评论 复制链接分享
  • dongzhui9936 dongzhui9936 2014-12-30 07:44

    use " " instead of ' '

    $trans_table["'"] = "'";

    You are using [singlequote singlequote singlequote] instead use [doublequote singlequote doublequote]

    点赞 评论 复制链接分享
  • doumei8126 doumei8126 2014-12-30 07:46

    I suppose that you probably have had different strictness settings for your PHP on old server. In there the error isn't reported and execution has continued. The error seems to be quite obvious, though:

    $trans_table['''] = "'";


    $trans_table['''] = "'";

    The part between [] has three ' in it after the ' is interpret as '. Use "" instead around it and should work.

    点赞 评论 复制链接分享
  • douling8087 douling8087 2014-12-30 07:48

    You have three single-quote characters between the square brackets: [''']. It looks like PHP is interpreting the first two single-quote characters as a zero-length string, and then getting confused how to interpret the third single-quote.

    I expect that the version of PHP, or the error-reporting configuration, differs between the old server and the new. The old server let the error slide, the new one is telling you about it.

    Similar to existing questions, Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in PHP and Error Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING

    点赞 评论 复制链接分享