ollie007 Posted June 7, 2009 Share Posted June 7, 2009 what does " $var ? $var : ' ' " mean? check var from var, default '' where can i learn more about it? Quote Link to comment Share on other sites More sharing options...
XaeroDegreaz Posted June 7, 2009 Share Posted June 7, 2009 That is a shorthand way of writing an if statement.. http://www.tech-recipes.com/rx/288/php-if-statement-syntax/ http://www.scottklarr.com/topic/446/shorthand-php-if-statement-without-the-else-notation/ $variable = (statement) ? "return if true" : "return if false"; //# Compared to if(statement) { $variable = "return this if true"; } else { $variable = "return this if false"; } Quote Link to comment Share on other sites More sharing options...
alco19357 Posted June 7, 2009 Share Posted June 7, 2009 $var ? $var : ' ' if $var is set, then echo $var, else echo ' ' you would need an echo in front of $var though Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 7, 2009 Share Posted June 7, 2009 It's called a ternary statement. alco19357, that's not exactly true. It's not so much if $var is set, but more like if (bool) $var is true. It doesn't exactly echo. It really depends on what's before the ternary statement in that line. Quote Link to comment Share on other sites More sharing options...
ollie007 Posted June 7, 2009 Author Share Posted June 7, 2009 ty all !! and yes it came from an isset statemet but i wanted to learn the basics Quote Link to comment Share on other sites More sharing options...
XaeroDegreaz Posted June 7, 2009 Share Posted June 7, 2009 Welcome to the PHP family, an everlasting quest of finding new ways to make computers do your bidding 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.