@solidaritiauthorSep 21.2005 — #This doesnt seem to work, it says that there is an unexpected T_ECHO I've tried putting a semi colon between the two echo statements and : but that doesnt seem to work.
@NogDogSep 21.2005 — #PS: It is called the "ternary operator". More info on this page: http://www.php.net/manual/en/language.operators.comparison.php The expression [i](expr1) ? (expr2) : (expr3)[/i] evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.[/quote]
@Stephen_PhilbinSep 21.2005 — #Aye, weirdly, using the sort-hand if structure seems to return the selected result rather than execute it as a standard if structure would do.
@pyroSep 21.2005 — #Aye, weirdly, using the sort-hand if structure seems to return the selected result rather than execute it as a standard if structure would do.[/QUOTE]You are only supposed to use the ternary opperator when you want to return a value. ?
@SpectreReturnsSep 22.2005 — #And by return he doesn't mean using 'return'. He means returning a value to use later on in the script (but can be used for 'return' if you want).
[code=php] $test = ((true) ? "true" : "false"); // good use ((true) ? echo("hello") : print("sup")); // Bad use [/code]