Re: Explanation

From: Date: Thu, 29 Nov 2001 02:07:37 +0000
Subject: Re: Explanation
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75976@lists.php.net to get a copy of this message
The manual is rather sparse about the ternary operator, you may find one sentence about it here: http://php.he.net/manual/en/language.operators.comparison.php Basically if the expression before the ? evaluates to true then the whole expression evaluates to the expression after the ?. If the expression before the ? evaluates to false then the whole expression evaluates to the expression after the : This is a really effective shorthand for if..then...else if you are just going to assign different values to a variable based on the outcome of the if statement. Fred Gerard Samuel <trini0@optonline.net> wrote in message news:3C058F2C.3000108@optonline.net... > Hi. Im looking over someone else's code and I come across something I > dont understand and dont know where in the manual to look for it. > Here is an example ==> > > $string1 = (isset($string2)) ? $HTTP_GET_VARS['pid'] : ""; > > I have no idea what the '?' in the line and the ':' at the end, so I > have no way of interpreting what $string1 could be. > If you could point me to the page in the manual that would be great. > > Thanks... >

« previous php.general (#75976) next »