0
I would like to know how to make PHP detect if a variable is with the value between one of the values passed.
Explaining better I have a variable with a value, this value will make it include a file in the content and I need PHP to detect whether these value is greater than or equal to "value" and less than or equal to "value".
<?php
$var = "valor>";
if ( $var <= "100")
include "m3.html";
else{
if ( $var <= "40" && >= "99")
include "m1.html";
else{
if ( $var >= "39")
include "m2.html";
}
}
?>
As you can see the second if
which has two values greater than value and less than value has given me trouble, already put &
, &&
and and
and it doesn’t work out that PHP detects if a variable has a value between 40 and 99 to include M1.html.
You are using strings! You need to use numbers, or it will compare how many characters you have instead of the numeric value...
– Sergio
In this case the value of var is type number to var is a java script in 1° and 3° if you want to remove 2° if now when I try to check if the value is between 40 and 99 of the error, I wanted to know how to put to check if this var is between 40 and 99... @Sergio
– Eder
Instead of
$var <= "100"
you have to take out the quotes and have$var <= 100
. Makes sense the difference?– Sergio
It does, but the worst is that while we have two values <= and => wrong. Even if quotation marks This code snippet of the if error ( $var <= "40" && >= "99")
– Eder
Can’t be
a <= b
andb => c
at the same time. In other words, it is a case, whena == c
.– Sergio
Do not have anything to check if var this among these values???
– Eder
Can you make a table with the cases you want/have? so we can help more in logic and code...
– Sergio