Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

If statement inside variables use

I try to check a condition using php variable like..

if ($amount. $row['condition']. $row['amount']) {
    return true;
} else {
    return false;
}

but the condition always return true value ,i also echo the single variable it will show the value and also do dd($amount. $rom['condition']. $rom['amount']); it will show "500>1000" ,i remove the double qutes and manually past value in if condition it will show false with this condition, how to solve and write this condition ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use eval()

$condition = $amount. $row['condition']. $row['amount'];
if (eval("return $condition;")) {
    return true;
} else {
    return false;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading