[SOLVED] What function does the "?" serve in this

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
chas688
Forum Newbie
Posts: 15
Joined: Wed Jul 14, 2004 3:25 pm

What function does the "?" serve in this code????

Post by chas688 »

I have looked in the Php manual, and looked at all the operators, etc. I can't find any reference to the "?" being used in a function the way that it is used here:

Code: Select all

$text_on_over = (!is_null($text_on_over)) ? $text_on_over : $text;
Will someone please tell me about this short cut or whatever it means?? Is it some sort of assignment operator?

Thanks,
Chas
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

http://www.php.net/manual/en/language.o ... arison.php

Basically,
if(condition) ? do this : else do this;
Last edited by markl999 on Wed Jul 14, 2004 3:35 pm, edited 2 times in total.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

It's the ternary comparison operator
chas688
Forum Newbie
Posts: 15
Joined: Wed Jul 14, 2004 3:25 pm

Thanks

Post by chas688 »

OK, that's what I needed to know. Thanks for helping a Newbie out!

~Chas
Post Reply