[nycphp-talk] What are ? and :
Aaron Fischer
agfische at email.smith.edu
Fri Sep 30 13:30:06 EDT 2005
Awesome, thanks for the description! That's very helpful, as is the
link as well.
I'd like to say that this list rocks, as usual.
Cheers,
-Aaron
Michael Sims wrote:
>On Friday 30 September 2005 12:36, Aaron Fischer wrote:
>
>
>
>>The symbols in question are ? and :
>>
>>
>
>?: is the "ternary operator". Google for that and you should get plenty of
>information.
>
>http://ca.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary
>
>A ? B : C
>
>can be roughly translated as "test A, and pick B or C depending on how A's
>test came out".
>
>
>
>>1) $argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : NULL;
>>
>>
>
>So this is saying if the _SERVER variable argv is set, then set the local
>variable argv with that value; otherwise set it to NULL. The more direct
>approach:
>
>$argv = $_SERVER['argv'];
>
>will throw an error if $_SERVER['argv'] doesn't exist. (Actually, it will
>throw a notice, not an error, and the script will continue to execute, and
>the functional effect will be very similar, but using the ternary operator
>is certainly more elegant.)
>
>
More information about the talk
mailing list