Jump to content


Photo

Short syntax for if statments


  • Please log in to reply
2 replies to this topic

#1 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 17 July 2006 - 10:43 AM

I cant find the short way of doing if statments using the ? and :

Does anyone know what it is? Thanks in advance.

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 17 July 2006 - 10:46 AM

? and : are called ternary conditional operators

#3 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 17 July 2006 - 10:47 AM

Ok, thanks. I got what i was looking for:
($var == 1) ? "yes" : "no";




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users