!解析错误:语法错误,意外的“public”(T_PUBLIC)

时间:2021-12-14 22:35:27

I'm transferring a wordpress site locally so I can develop safely, I'm very new to all this and have come across this error, so if you could explain in simple terms how to fix then that would be very helpful:

我在本地转移一个wordpress站点,这样我就可以安全地开发了,我对这一切都很陌生,也遇到了这个错误,所以如果你能简单地解释一下如何修复,那将非常有帮助:

!Parse error: syntax error, unexpected 'public' (T_PUBLIC) in 
C:\wamp\www\KentVenuesTest\wp-content\mu-plugins\wpengine-common\plugin.php
on line 408

Call Stack

#  Time    Memory   Function
1.0.0007 - 247624 - {Main}()<p>
2.0.0014 - 251160 - require ('C:\wamp\www\KentVenuesTest\wp-blog-header.php')<p>
3.0.0022 - 268032 - require_once('C\wamp\www\KentVenuesTest\wp-load.php')<p>
4 0.0029 - 279728 - require_once('C\wamp\www\KentVenuesTest\wp-config.php')<p>
5 0.0041 - 370928 - require_once('C\wamp\www\KentVenuesTest\wp-settings.php')<p>
6 0.2186 - 13379696 - 4 -0.0029 - 279728 - include_once('C\wamp\www\KentVenuesTest\mu-plugins\mu-plugin.php<p>

Location

1 ..\index.php:0<p>
2 ..\index.php:17<p>
3 ..\wp-blog-header.php:12<p>
4 ..\wp-load.php:29<p>
5 ..\wp-config.php:90<p>
6 ..\wp-settings.php:159<p>

Any help would be greatly appreciated.

如有任何帮助,我们将不胜感激。

4 个解决方案

#1


8  

The problem may be in php configuration differences. E.g. I once faced similar problem, your situation reminds me that. It was caused by php configuration related to short <?php syntax which allows to use <? instead. On test envirionment <? works on production doesn't

问题可能出在php配置上。我曾经遇到过类似的问题,你的情况提醒我。它是由与short

#2


0  

Either line 408 has an error, missing a semi-colon or something that's making the next line choke, or you could be using a super old version of php which doesn't support classes though I would expect that to hose earlier on. Could it be that you're trying to run a PHP 5 script on PHP 4?

或者是第408行出现了错误,缺少了一个分号,或者是导致下一行阻塞的东西,或者您可能使用的是一个非常旧的php版本,它不支持类,但是我期望它会在前面继续。你是不是想在PHP 4上运行一个PHP 5脚本?

The public keyword can only be used in the class context in php, maybe that gives you a clue. May be yo have mistakenly used it somewhere else.

public关键字只能在php的类上下文中使用,这可能为您提供了线索。可能是你把它错用在别的地方了。

Make sure all your braces are closed {}

确保所有的大括号都是关闭的{}

'localhost' should work fine for the DB but other includes path should be correct.

“localhost”对于DB应该可以正常工作,但是其他包含路径应该是正确的。

You might be using <? instead of <?php. Try to swich to <?php

您可能正在使用

#3


0  

There is a syntax error on or before line 408 in file C:\wamp\www\KentVenuesTest\wp-content\mu-plugins\wpengine-common\plugin.php

在文件C的第408行或之前有一个语法错误:\wamp\www\KentVenuesTest\wp-content\mu-plugins\wpengine-common\plugin.php

When the parser reaches the token "public" on line 408 it's confident that there must have been a mistake somewhere since it did not expect to see the token "public".

当解析器在第408行到达令牌“public”时,它确信一定有错误,因为它不希望看到令牌“public”。

#4


0  

PHP is complaining that the code has a syntax error in it.

PHP抱怨代码有语法错误。

Since it looks like you're only using third-party code, I would guess that there isn't actually a syntax error in the code, but more likely you are trying to run it on a version of PHP that is incompatible with it.

由于看起来您只是在使用第三方代码,所以我猜测代码中实际上并没有语法错误,但更有可能是您试图在与之不兼容的PHP版本上运行它。

What versions of PHP are on your remote server (ie where it works(?)) compared with your local machine (ie where it doesn't work)?

与本地计算机(即不工作的服务器)相比,远程服务器上的PHP版本是什么?

I would guess you've probably got an old version of PHP on the one that doesn't work. Try upgrading it; the best would be to make sure that both the dev and live sites are running the same PHP version, but it shouldn't matter too much that they're exactly the same as long as they're both sufficiently up-to-date to run the code.

我猜你可能已经有一个旧版本的PHP在那个不工作的。试着升级;最好的方法是确保开发站点和活动站点都运行相同的PHP版本,但是只要它们都是最新的,可以运行代码,那么它们是完全相同的就不太重要了。

#1


8  

The problem may be in php configuration differences. E.g. I once faced similar problem, your situation reminds me that. It was caused by php configuration related to short <?php syntax which allows to use <? instead. On test envirionment <? works on production doesn't

问题可能出在php配置上。我曾经遇到过类似的问题,你的情况提醒我。它是由与short

#2


0  

Either line 408 has an error, missing a semi-colon or something that's making the next line choke, or you could be using a super old version of php which doesn't support classes though I would expect that to hose earlier on. Could it be that you're trying to run a PHP 5 script on PHP 4?

或者是第408行出现了错误,缺少了一个分号,或者是导致下一行阻塞的东西,或者您可能使用的是一个非常旧的php版本,它不支持类,但是我期望它会在前面继续。你是不是想在PHP 4上运行一个PHP 5脚本?

The public keyword can only be used in the class context in php, maybe that gives you a clue. May be yo have mistakenly used it somewhere else.

public关键字只能在php的类上下文中使用,这可能为您提供了线索。可能是你把它错用在别的地方了。

Make sure all your braces are closed {}

确保所有的大括号都是关闭的{}

'localhost' should work fine for the DB but other includes path should be correct.

“localhost”对于DB应该可以正常工作,但是其他包含路径应该是正确的。

You might be using <? instead of <?php. Try to swich to <?php

您可能正在使用

#3


0  

There is a syntax error on or before line 408 in file C:\wamp\www\KentVenuesTest\wp-content\mu-plugins\wpengine-common\plugin.php

在文件C的第408行或之前有一个语法错误:\wamp\www\KentVenuesTest\wp-content\mu-plugins\wpengine-common\plugin.php

When the parser reaches the token "public" on line 408 it's confident that there must have been a mistake somewhere since it did not expect to see the token "public".

当解析器在第408行到达令牌“public”时,它确信一定有错误,因为它不希望看到令牌“public”。

#4


0  

PHP is complaining that the code has a syntax error in it.

PHP抱怨代码有语法错误。

Since it looks like you're only using third-party code, I would guess that there isn't actually a syntax error in the code, but more likely you are trying to run it on a version of PHP that is incompatible with it.

由于看起来您只是在使用第三方代码,所以我猜测代码中实际上并没有语法错误,但更有可能是您试图在与之不兼容的PHP版本上运行它。

What versions of PHP are on your remote server (ie where it works(?)) compared with your local machine (ie where it doesn't work)?

与本地计算机(即不工作的服务器)相比,远程服务器上的PHP版本是什么?

I would guess you've probably got an old version of PHP on the one that doesn't work. Try upgrading it; the best would be to make sure that both the dev and live sites are running the same PHP version, but it shouldn't matter too much that they're exactly the same as long as they're both sufficiently up-to-date to run the code.

我猜你可能已经有一个旧版本的PHP在那个不工作的。试着升级;最好的方法是确保开发站点和活动站点都运行相同的PHP版本,但是只要它们都是最新的,可以运行代码,那么它们是完全相同的就不太重要了。