eXtreme eXtreme - 5 months ago 8
PHP Question

IF statement with multiple expressions

I'm trying to construct IF statement with multiple conditions but I can't get echo 'TRUE' with this PHP code.

<?php
$totalDays = 4;
$startDateL = 'Friday';
$endDateL = 'Monday';
$pickupTime = '12:00:00';
$returnTime = '9:00:00';

if($totalDays == 4 AND
$pickupTime == '12:00:00' AND
$returnTime == '09:00:00' AND
$startDateL == 'Friday' AND
$endDateL == 'Monday') {
echo 'TRUE';
}
?>

Answer

Your $returnTime is '9:00:00', but you compare it against '09:00:00' in your condition.

Comments