lundi 5 octobre 2015

Parse error unexpected '{' [duplicate]

This question already has an answer here:

I'm struggling with my website which doesn't want to open anymore. After a complete re-upload of wordpress I get this error :

Parse error: syntax error, unexpected '{' in /home/orchestrw/www/wp-includes/functions.php on line 2678

Here are the few lines :

        if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) )  {
        return $json;
    }

    try {
        $args[0] = _wp_json_sanity_check( $data, $depth );
    } catch ( Exception $e ) {
        return false;
    }
{
    return call_user_func_array( 'json_encode', $args );
}

The line 2678 is "try {" Thanks for your help Jean

The complete code is too big to post here, I've added a few lines from higher up

    function wp_json_encode( $data, $options = 0, $depth = 512 ) {
    /*
     * json_encode() has had extra params added over the years.
     * $options was added in 5.3, and $depth in 5.5.
     * We need to make sure we call it with the correct arguments.
     */
    if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) {
        $args = array( $data, $options, $depth );
    } elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
        $args = array( $data, $options );
    } else {
        $args = array( $data );
    }

    $json = call_user_func_array( 'json_encode', $args );

    // If json_encode() was successful, no need to do more sanity checking.
    // ... unless we're in an old version of PHP, and json_encode() returned
    // a string containing 'null'. Then we need to do more sanity checking.
    if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) )   {
        return $json;
    }

    try {
        $args[0] = _wp_json_sanity_check( $data, $depth );
    } catch ( Exception $e ) {
        return false;
    }
{
    return call_user_func_array( 'json_encode', $args );
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire