意外的T_REQUIRE_ONCE应该是预期的

时间:2011-04-25 21:27:20

标签: php

<?php

/*
 * userprofile.php
 * bshades.com
 * Coded by Orgy
 * rrawbb[at]gmail[dot]com
 */

require_once("inc/_top.php");

这是我的代码有问题。

以下是错误消息:

  

解析错误:语法错误,意外的T_REQUIRE_ONCE   第1行/home/blacksha/public_html/userprofile.php

如您所见,require_once甚至不在第1行,所以我不知道问题是什么。

2 个答案:

答案 0 :(得分:4)

NBSP。在require语句之前,您有一个不可见的非标准空白字符。这是重现此错误的唯一可靠方法。

eval(    chr(0xA0) . ' require_once(1); ' );
      # that's nbsp

// PHP Parse error:  syntax error, unexpected T_REQUIRE_ONCE in 

0xA0 / nbsp在该位置被解释为裸字。基本上与在陈述前面有一个不变的权利相同:

ASCII require_once(123);

答案 1 :(得分:2)

如果您忘记了尾随的分号,也可以重现此错误代码;终止声明...

define('FOO', 'foo')
require_once('foo.php');