TapeGun007 Posted March 28, 2010 Share Posted March 28, 2010 Is it possible to make a variable If statement? Example: If scenario1 = True Then $statement = "Date>CurrentDate" Else $statement="Date<CurrentDate" . . . If ($statement){ [output results] } Or... is there just a better way of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/196748-are-variable-if-statements-possible/ Share on other sites More sharing options...
Zane Posted March 28, 2010 Share Posted March 28, 2010 Yes.. they're called ternary statements. example $lightbill = "ridiculous"; $amIbroke = ($lightbill == "paid") ? false: true; echo $amIbroke ? "Yes" : "No, but you soon will be anyway"; Quote Link to comment https://forums.phpfreaks.com/topic/196748-are-variable-if-statements-possible/#findComment-1032896 Share on other sites More sharing options...
TapeGun007 Posted March 28, 2010 Author Share Posted March 28, 2010 Ah ok... thank you! Quote Link to comment https://forums.phpfreaks.com/topic/196748-are-variable-if-statements-possible/#findComment-1032897 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.