Posted by Jim Michaels on 03/02/06 23:44
"Smiley" <none@ofyourbusiness.com> wrote in message
news:a_idnaymMdq5xmfeRVn-iw@golden.net...
>I taught myself PHP a few years ago and I use it frequently. Recently I
>downloaded a PHP script built by somebody else, and came across this piece
>of code:
>
> $password = isset($HTTP_POST_VARS['password']) ?
> $HTTP_POST_VARS['password'] : '';
>
> I have never seen the question mark or colon used in this way before. I
> can't find any reference to it in my PHP book. Please tell me what it
> means.
>
It's called the ternary operator - it's a holdover from C/C++. JavaScript,
Java, and Perl have it too.
http://us2.php.net/manual/en/language.operators.comparison.php
it's in the manual around the middle of the page I think. it's in the CHM
manual under operators, comparison.
[Back to original message]
|