M.O.S. Studios Posted April 17, 2009 Share Posted April 17, 2009 hey guys, is it possible to place a if() statement's argument in a variable, for example $test="1<=2;"; if($test){echo "it works";}else {echo "it doesn't work";} that will display "it works" but $test="3<=2;"; if($test){echo "it works";}else {echo "it doesn't work";} will display "it doesn't work" I'm assuming if I place the entire if statement in an variable then run it threw eval(); it will work, but i rather not do that. Quote Link to comment Share on other sites More sharing options...
ober Posted April 17, 2009 Share Posted April 17, 2009 That will not work. I think the only reason the first one works is because it only reads the first part of your "equation", which is a 1. Quote Link to comment Share on other sites More sharing options...
Maq Posted April 17, 2009 Share Posted April 17, 2009 Maybe a ternary? $test= (3 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.