PHP 解析错误; Drupal6部署
我在 www.example.com/test
上安装了 Drupal。现在,它已准备好上线,我正尝试将其移至 www.example.com
。我将 sites/default/settings.php
中的行更改为:
$base_url = 'http://www.example.com/'; // NO trailing slash!
当我导航到 index.php 时,我收到各种解析错误,如下所示:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'
in /home/example/public_html/sites/all/modules/typogrify/typogrify.class.php
on line 18
问题是这样的:
public static function amp($text) {
$amp_finder = "/(\s| )(&|&|&\#38;|&)(\s| )/";
return preg_replace($amp_finder, '\\1<span class="amp">&</span>\\3', $text);
}
每个函数都像这样正在导致错误。那么 PHP 是否不再理解这种以前在子目录中运行得很好的语法?
I had a Drupal installation at www.example.com/test
. Now, it's ready to go live, and I am trying to move it to www.example.com
. I changed the line in sites/default/settings.php
to:
$base_url = 'http://www.example.com/'; // NO trailing slash!
When I navigate to my index.php, I get all sorts of parse errors, like this:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'
in /home/example/public_html/sites/all/modules/typogrify/typogrify.class.php
on line 18
The problem is this:
public static function amp($text) {
$amp_finder = "/(\s| )(&|&|&\#38;|&)(\s| )/";
return preg_replace($amp_finder, '\\1<span class="amp">&</span>\\3', $text);
}
Every function like this is causing errors. then does PHP no longer understand this syntax that worked perfectly fine before in a subdirectory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IIRC,这是在 PHP 4 中尝试使用可见性声明(私有/受保护/公共)时遇到的错误。 您的实时环境是否使用与测试环境不同的 PHP 版本?
Drupal 6 核心应该仍然与 PHP 4 兼容,但许多模块则不然,因为 PHP 4 不再被维护,并且自 2008 年 8 月以来没有得到任何安全修复程序。因此,将其用于生产站点是一个很大的安全问题。
因此,在投入任何时间“修复”此问题之前,我建议立即切换到 PHP 5。
可能与您的问题无关,但您是否阅读了设置
$base_url 行上的注释变量?您应该删除尾部斜杠,以防您的真实 URL 中也有它。
编辑:刚刚从有问题的文件中检查了“Typogrify”类。它似乎只是静态方法(函数)的集合。因此,如果这是唯一给您带来问题的文件,您可以通过删除其中的所有“公共”声明来解决此问题,因为它们并不是绝对必要的。
请注意,我不建议这样做 - 您不应该使用已弃用、未维护的 PHP 版本运行生产站点!)
IIRC, that is the error one got when trying to use visibility declarations (private/protected/public) in PHP 4. Could it be that your live environment uses a different PHP version than your testing environment?
While Drupal 6 core is supposed to still be compatible with PHP 4, many modules are not, as PHP 4 is not maintained anymore and does not get any security fixes since August 2008. Using it for a production site is therefore a big NO security wise.
So before investing any time in 'fixing' this, I'd recommend switching to PHP 5 immediately.
Probably unrelated to your problem, but did you read the comment on the line setting the
$base_url
variable? You should remove the trailing slash, in case you also have it there with your real URL.Edit: Just checked the 'Typogrify' class from the offending file. It seems to be just a collection of static methods (functions). So if that is the only file giving you problems, you might be able to work around this by removing all the 'public' declarations in there, as they are not strictly necessary.
Note that I do not recommend this - you should not run a production site with a deprecated, unmaintained PHP version!)
没有尾部斜杠! ;)
NO trailing slash! ;)