If i have a variable like this on php :
$codition = "question_1 == a AND question_2 == b";
is there any way to replace the value to be like this :
$codition = "$question_1 == 'a' && $question_2 == 'b'";
This variable I can use in this condition:
if(echo $codition){
echo "Success";
} else {
echo "fail";
}
The reason I use a variable on condition (if else) because I have a rule in the database, and the value looks like the first value on the variable $codition
, is it possible to replace a word on variable and using it on elseif
statements?
I think you are off track entirely with your question. Below I attempt to get at your question, but making an educated guess at what you are asking.
Assume:
Var $codition is a condition to check if 'a' or 'b'
Vars $q1codition and $q2codition are used to hold these strings 'a' and 'b'
Then:
$q1codition = 'a';
$q2codition = 'b';
if($codition == $q1codition && $codition == $q2codition){
echo "Success";
} else {
echo "fail";
}
Is this what you are getting at?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.