2

im trying to fix a bug with Wp-Bakery Wordpress builder after updating the system to PHP8.

The error is Fatal error: Unparenthesized a ? b : c ? d : e is not supported. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e)

Here is the code:

        $host = isset( $s['HTTP_X_FORWARDED_HOST'] ) ? $s['HTTP_X_FORWARDED_HOST'] : isset( $s['HTTP_HOST'] ) ? $s['HTTP_HOST'] : $s['SERVER_NAME'];

I can't see my website, i tried to modify the code but with no success.

1 Answers1

0

Well if you've tried the proposed solution, which is:

$host = isset( $s['HTTP_X_FORWARDED_HOST'] ) ? $s['HTTP_X_FORWARDED_HOST'] : (isset( $s['HTTP_HOST'] ) ? $s['HTTP_HOST'] : $s['SERVER_NAME']);

Then you could try and turn it into a function:

function example() {
    if (isset( $s['HTTP_X_FORWARDED_HOST'] )) {
        return $s['HTTP_X_FORWARDED_HOST'];
    } else if(isset( $s['HTTP_HOST'] )) {
        return $s['HTTP_HOST'];
    } else {
        return $s['SERVER_NAME'];
    }
}

$host = example();