HTTP Error 500 when using ternary operator in PHP

59 views Asked by At

I recently updated the php version on my family tree website from 7.4 to 8.1 and also enabled SSL Certificate to get rid of the "this website is not secure" message. Now my page generates an Error 500 when using a ternary operator. What am I doing wrong?

Before I had this line:

echo '<p><b>Sex</b> : ' . (('U' == $fp_sex) ? 'Unknown / Undefined' : ('M' == $fp_sex) ? 'Male' : 'Female') . '</p>';

I have had to update to the following to get the page to load correctly:

echo '<p><b>Sex</b> : ';
    if ('U' == $fp_sex)
    {
        echo 'Unknown / Undefined';
    }
    else
    {
        if ('M' == $fp_sex)
        {
            echo 'Male';
        }
        else
        {
            echo 'Female';
        }
    }   
echo '</p>';

I'm not sure if updating the php version supported or enabling the SSL certificate cause this problem.

Any help would be greatly appreciated.

0

There are 0 answers