【问题标题】:Parse error: syntax error, unexpected T_FUNCTION Please help includes/theme_filters.php解析错误:语法错误,意外的 T_FUNCTION 请帮助包括/theme_filters.php
【发布时间】:2014-02-01 15:04:37
【问题描述】:

在我的服务器上使用我的 wordpress 主题时出现以下错误,任何人都可以帮助解释为什么会发生这种情况。

解析错误:语法错误,第 1 行 /wp-content/themes/BookYourTravel/includes/theme_filters.php 中的意外 T_FUNCTION

这些是该文件中提到的代码

<?php
    /** * Remove password email text if option for users to set their own password is enabled in Theme settings. */
    function remove_password_email_text ( $text ) 
    {   
        $let_users_set_pass = of_get_option('let_users_set_pass', 0);   

        if ($text == 'A password will be e-mailed to you.' && $let_users_set_pass)  
            $text = ''; 
            return $text;
        }

        add_filter( 'gettext', 'remove_password_email_text' );
?>

【问题讨论】:

  • 你应该格式化你的代码..

标签: php wordpress


【解决方案1】:

您缺少一个{ 和一个}

这里:

if ($text == 'A password will be e-mailed to you.' && $let_users_set_pass) 
{ // <-- here is the missing {
    $text = ''; 
    return $text;
}

这里:

} // <-- here is the missing }
add_filter( 'gettext', 'remove_password_email_text' );

?>

【讨论】:

  • 右大括号应该在 add_filter();
  • @NathanDawson,谢谢,我不知道 wordpress 的功能 :-)
【解决方案2】:

请从服务器下载 theme_filters.php 文件并检查其格式是否正确或代码仅一行。如果代码在一行中,只需对其进行格式化。当我在服务器上检查我的文件时,我遇到了同样的问题,它显示的代码如下:

<?php/*some comment here*/function xyz...?>

我这样格式化这个文件:

<?php 
/*some comment here*/

function xyz...
.
.
.
?>

现在它对我来说工作正常。

祝你好运……

【讨论】:

    猜你喜欢
    • 2011-09-22
    • 2012-05-11
    • 2011-06-24
    • 1970-01-01
    • 1970-01-01
    • 2015-05-26
    • 2011-07-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多