Mr.Shawn Posted February 9, 2008 Share Posted February 9, 2008 $requested = empty($_SERVER['REQUEST_URI']) ? false : $_SERVER['REQUEST_URI']; What does the above code means? What's with the ? and : Quote Link to comment Share on other sites More sharing options...
rlindauer Posted February 9, 2008 Share Posted February 9, 2008 Look up the ternary operator. http://us3.php.net/language.operators.comparison Quote Link to comment Share on other sites More sharing options...
phpknight Posted February 9, 2008 Share Posted February 9, 2008 It means if that if $_SERVER['REQUEST_URI'] is not set, then $requested is false. Otherwise, it is set to its value. ? : is an easy way to do quick if/else syntax $value=($number<0)? "negative": "positive"; If the condition in (here) is true, the $value gets set to the first value. If not, it's the second one. Of course zero is not really positive, but you get the point. Quote Link to comment Share on other sites More sharing options...
Mr.Shawn Posted February 16, 2008 Author Share Posted February 16, 2008 Well explained. Thank you so much. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted February 16, 2008 Share Posted February 16, 2008 you know what, this is how i understood it first $var = ($var == "a") ? "the var $var is now this string" : "If the var does not equal A, then the $var is equalled to this string"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.