Is this possible?
$var_1 = 1;
$var_2 = 10;
$comparison = '>';
if($var_1 $comparison $var_2) {
// do something...
}
The syntax right now is not valid but is there a way to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not natively (except of course with
eval). You will need to evaluate the various expressions yourself. Build a wrapper function and use aswitchstatement. Or for non-expression comparisons a simple map: