benphp Posted May 17, 2013 Share Posted May 17, 2013 For example, can I do: if ($test == "yes") $myOp = ">"; } else { $myOp = "<"; } I know this doesn't work, but is there a way to do this with curly brackets? And then: if (($img == "0" && $textCount $myOp 1000) || $img == "") { //do this } Link to comment https://forums.phpfreaks.com/topic/278111-can-you-make-a-comparison-operator-a-variable/ Share on other sites More sharing options...
Jessica Posted May 17, 2013 Share Posted May 17, 2013 You could use eval() but most likely you're doing something else wrong. Link to comment https://forums.phpfreaks.com/topic/278111-can-you-make-a-comparison-operator-a-variable/#findComment-1430745 Share on other sites More sharing options...
Psycho Posted May 17, 2013 Share Posted May 17, 2013 This would be better $firstTest = ($test == "yes") ? ($textCount > 1000) : ($textCount < 1000); if (($img == "0" && $firstTest) || $img == "") { //do this } Link to comment https://forums.phpfreaks.com/topic/278111-can-you-make-a-comparison-operator-a-variable/#findComment-1430746 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.