PHP help

afcbob

New member
Hello i am learning php just now and am using a training course to learn.But i have a problem am trying to use the && but can't get it to work.
This is the code it say to use:

if (($a > 100) && ($a <2000)) {
echo "number is greater than 100 but less than 2000";
}

i have tried moving the $a values up and down but just can't get this to work.
Please help me out.

if i don't get it soon i will have no hair left at all :crash:
 
just add the value of $a

before the if statement then a has a value and the statement can check if its true,

whole thing would look like this

<?php
//value of a, a is equal to 220
$a = '220';

//if a is greater than 100 and less than 2000
if (($a > 100) && ($a <2000)) {

//output number is greater than 100 but less than 2000
echo "number is greater than 100 but less than 2000";

//if the number isnt greater than 100 and less than 2000
} else {

//output, number is less than 100 or greater than 200
echo "number is less than 100 or greater than 2000";
}
?>

ps: added comments to explain the code.
 
Last edited:
Top