Re: [PHP] what does this mean in plain english?
On 17 May 2002 at 12:23, Jeff Field wrote: $theValue = ($theValue != ) ? ' . $theValue . ' : NULL; It's a shortened version of the if...else construct. As in... condition ? this_if_true : this_if_false -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what does this mean in plain english?
On Fri, May 17, 2002 at 12:23:45PM -0500, Jeff Field wrote: I'm stumped by the exact meaning in the following function of what the question mark's (?) and colon's (:), mean and do? That's the ternary comparison operator. See http://www.php.net/manual/en/language.operators.comparison.php, then scroll down under the top table. $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; For explanation, allow me to change this a tad... $newValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; So, in english... If magic quotes gpc is off, set $newValue to addslashes($theValue). If magic quotes gpc is NOT off, set $newValue to plain old $theValue. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what does this mean in plain english?
The ? in this senario is called the ternary operator basically shorthand for an if/else statement e.g $theValue = ($theValue != ) ? ' . $theValue . ' :NULL; is the equivalent of if($theValue != ) { $theValue =$theValue ; } else{ $theValue =NULL; } - Original Message - From: Jeff Field [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, May 17, 2002 6:23 PM Subject: [PHP] what does this mean in plain english? Hi. I'm fairly new to PHP and programming in general. I'm learning mostly by deconstructing what others have written...but even though I have plenty of PHP books and have searched the Internet high and low, I'm stumped by the exact meaning in the following function of what the question mark's (?) and colon's (:), mean and do? BTW, I'm not looking for an explanation of the function; just what the question mark's and colon's mean in plain english, so I'll know how to use them in other places. Thanks! Jeff -- function GetSQLValueString($theValue, $theType) { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case text: $theValue = ($theValue != ) ? ' . $theValue . ' : NULL; break; case int: $theValue = ($theValue != ) ? intval($theValue) : NULL; break; } return $theValue; } -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php