0

I know there are countless articles out there to read about php ternary operators, however, I have read a bunch but cannot get it to work.

This is my code without ternary operators:

    if ( get_field('fs_ski_resort_data_fs_name') != null && !empty(get_field('fs_ski_resort_data_fs_name') ) )
    {
        $the_name = get_field('fs_ski_resort_data_fs_name');
    } else  {
        $the_name = get_field('fs_ski_resort_data_osm_name');
    }   
    echo 'The name'.$the_name;

The above works, however, is the below doesn't produce the same result as above.

    $the_name = get_field('fs_ski_resort_data_fs_name') ?? $the_name = get_field('fs_ski_resort_data_osm_name');
    echo $the_name;

Please tell me my mistake.

spreaderman
  • 918
  • 2
  • 10
  • 39

0 Answers0