I could not find these question, altough i think this was already questioned.
Problem: If you want to build your IF Statement conditions with variables, like:
<?php
//DEFINE IF STATEMENT CONDITIONS INSIDE A VARIABLE
$var = '$t == 1';
$var .= ' AND $x == 1';
//END OF DEFINE IF STATEMENT CONDITIONS
//DEFINE VARIABLES
$t = "1";
$x = "2";
//END OF DEFINE VARIABLES
//NOW CHECK THE IF STATEMENT, YOU CAN SEE THE CONDITION SHOULD BE FALSE BECAUSE $x != 1
if( print($var) == TRUE)
{ echo "TRUE"; }
else
{ echo "FALSE"; }
//I KNOW THE CODE (print($var) == TRUE) WONT WORK, ONLY SHOWN FOR A BETTER UNDERSTANDING
?>
The If statement above just proofs if the variable exists, but i want to proof if the content of the variable is true: $t == 1 AND $x == 1.
The IF statement in the code above should be similar to:
if( $t == 1 AND $x == 1)
{ echo "TRUE"; }
else
{ echo "FALSE"; }
I tried a lot. Now i would be happy for a solution, which includes an If statement in the form of If (PROOF CONTENT OF VARIABLE) {}
.
Aucun commentaire:
Enregistrer un commentaire