homepage Welcome to WebmasterWorld Guest from 23.23.22.200
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP and ?
circuitjump




msg:1309809
 7:50 pm on Aug 16, 2001 (gmt 0)

Quick question.

What does the ? (question mark) do in PHP?

Or more to the point.

I'm trying to convert this javascript

X = (!X ? 2 : X);

to PHP

It's supposed to mean I think

if X is not true then use X, else if it is true then use 2

I think

Thanks

 

toadhall




msg:1309810
 9:34 pm on Aug 16, 2001 (gmt 0)

Ternary operator.

$first ? $second : $third
If the value of the first subexpression is TRUE (non-zero), then the second subexpression is evaluated, and that is the result of the conditional expression. Otherwise, the third subexpression is evaluated, and that is the value.

[php.net...] (find: ternary)


circuitjump




msg:1309811
 2:30 pm on Aug 17, 2001 (gmt 0)

You know I could not find this information in any of my PHP books. And I got three of them.

Thanks for the answer

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved