Parse error: syntax error, unexpected T_FUNCTION P

2019-09-20 07:30发布

问题:

Please getting following Error while using me wordpress theme on my server can anyone please help out with the reason why this happening.

Parse error: syntax error, unexpected T_FUNCTION in /wp-content/themes/BookYourTravel/includes/theme_filters.php on line 1

These are code which is mention in that file

<?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' );
?>

回答1:

You are missing one { and one }

here:

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

and here:

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

?>


回答2:

Please download theme_filters.php file from server and check is it proper formatted or code is coming just one line. If code is coming in one line just format it. I got same issue when i check my file on server its was showing code like this:

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

I formatted this file like this:

<?php 
/*some comment here*/

function xyz...
.
.
.
?>

Now its working fine for me.

Good luck...



标签: php wordpress