PHP函数错误在现场服务器,但不是在我的本地机器



我们使用的平台是wordpress。Wordpress在实时服务器上工作。我正在试着让它在我的本地机器上工作。

当我替换本地机器中的wordpress文件时,会出现这个错误

解析错误:语法错误,意想不到的'public' (T_PUBLIC) in C:wampwwwmywordpressdirectorywp-contentmu-pluginswpengin -commonplugin.php on line 788

这行有这个函数

public function disable_indiv_plugin_update_notices( $value ) {
    $plugins_to_disable_notices_for = array();
    $basename = '';
    foreach ($plugins_to_disable_notices_for as $plugin) {
        $basename = plugin_basename( $plugin );
    }
    if (isset($value->response[@$basename])) {
        unset( $value->response[$basename] );
    }
    return $value;
}

我没有发现这个函数有任何错误。此函数之前的上述内容为

function wpengine_credits() {
    if (get_option('stylesheet') != 'twentyeleven' && get_option('template') != 'twentyeleven') {
        return false;
    }
    if (!defined('WPE_FOOTER_HTML') OR !WPE_FOOTER_HTML OR $this->already_emitted_powered_by == true) {
        return false;
    }
    //to prevent repeating
    $this->already_emitted_powered_by = true; ?>
    <div id="site-host">
            WP Engine <a href="http://wpengine.com" title="<?php esc_attr_e( 'Managed WordPress Hosting', 'wpengine' ); ?>"><?php printf( __( '%s.', 'wpengine' ), 'WordPress Hosting' ); ?></a>
    </div>
    <?php
}

生产服务器使用的是5.5.9-1ubuntu4.11,而我的本地工作站使用的是5.5.12

unexpected 'public' (T_PUBLIC)给出了这个问题。

public function disable_indiv_plugin_update_notices( $value ) {

应该是

function disable_indiv_plugin_update_notices( $value ) {

除非函数在类中,否则不需要关键字publicprotectedprivate(并且会破坏解析器)。

最新更新