Page 1 of 1

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

Posted: Wed Jul 14, 2004 3:25 pm
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

Posted: Wed Jul 14, 2004 3:33 pm
by markl999
http://www.php.net/manual/en/language.o ... arison.php

Basically,
if(condition) ? do this : else do this;

Posted: Wed Jul 14, 2004 3:34 pm
by redmonkey
It's the ternary comparison operator

Thanks

Posted: Wed Jul 14, 2004 3:37 pm
by chas688
OK, that's what I needed to know. Thanks for helping a Newbie out!

~Chas