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? 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"; 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! 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
Archived
This topic is now archived and is closed to further replies.