这一行wordpress PHP代码有什么问题?(出自教程)


What's wrong with this line of wordpress PHP code? (from a tutorial)

我知道这通常是不受欢迎的,但我从教程中学习了这一点,所以我对为什么它不起作用感到有点惊讶。

下面是受影响的代码行:

$document_root = rtrim(str_replace(array('/', '''), '/', $_SERVER['DOCUMENT_ROOT']), '/');

apache错误日志中的错误信息:

[Sun Jul 27 01:01:47 2014] [error] [client 24.62.230.8] PHP Parse error:  syntax error, unexpected 'DOCUMENT_ROOT' (T_STRING), expecting ')' in /home/folder/wp/wp-config.php on line 8
[Sun Jul 27 01:01:47 2014] [error] [client 24.62.230.8] PHP Stack trace:
[Sun Jul 27 01:01:47 2014] [error] [client 24.62.230.8] PHP   1. {main}() /home/folder/wp/index.php:0
[Sun Jul 27 01:01:47 2014] [error] [client 24.62.230.8] PHP   2. require() /home/folder/wp/index.php:3
[Sun Jul 27 01:01:47 2014] [error] [client 24.62.230.8] PHP   3. require_once() /home/folder/wp/wp-blog-header.php:12

上下文:这是我遵循的教程来实现这一点。查看wp-config.php - http://polycademy.com/blog/id/148/modern_wordpress_workflow_with_composer

试试这样:

$document_root = rtrim(str_replace(array('/', ''''), '/', $_SERVER['DOCUMENT_ROOT']), '/');