Results 1 to 3 of 3

Thread: PHP: Inline If

  1. #1

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935

    PHP: Inline If

    Is there a way to do an inline if in PHP, similar to IIf in VB and the "condition ? true : false" thing in Java/Javascript/C++?

  2. #2
    scoutt
    Guest
    I get what you mean now, I don't think there is. at least I haven't read or seen one yet.

  3. #3
    New Member
    Join Date
    Mar 2008
    Posts
    1

    Re: PHP: Inline If

    i know this is an old post but i thought i'd put an answer in case anyone else comes across this. there is a ternary operator that works similar to the javascript condition ? true : false but it returns the value derived from one of the expressions. so:

    PHP Code:
    $test 5;
    $myval = ($test 3) ? ("less than 3") : ("greater than or equal to 3");
    echo 
    $myval 
    returns:
    greater than or equal to 3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width