|
-
Feb 6th, 2002, 08:48 PM
#1
Thread Starter
Member
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++?
-
Feb 6th, 2002, 11:06 PM
#2
I get what you mean now, I don't think there is. at least I haven't read or seen one yet.
-
Mar 17th, 2008, 10:20 AM
#3
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|