• hi i am just wondering if some one could tell me what the “?” mean in php syntax.

    $post_cat = ( in_array( $_POST[‘post_cat’], $accepted_post_cats ) ) ? $_POST[‘post_cat’] : ‘status’;

    Cheers
    Nick

Viewing 1 replies (of 1 total)
  • That is called the ternary operator.

    $results =  ( logical expression )   ?
      ( result if expression is true ) : ( result if expression is false ) ;

    It’s the same as

    if ( logical expression ) {
       result if expression is true;
    } else {
       result if expression is false;
    }

    except it all goes on one line

Viewing 1 replies (of 1 total)
  • The topic ‘Simple php question’ is closed to new replies.