php - Function works when returning true or false but not when returning 0 or 1 -
function date2_in_the_past($day, $month, $year) { $datestring = $year . "-" . $month . "-" . $day; if (date ('y-m-d', strtotime($datestring)) < date('y-m-d', strtotime("now",time()))) { $b = 1; **// want $b = true**; } else { $b = 0; **// want $b = false;** } return $b; } //echo date2_in_the_past(24, 10, 2013); // returns 0
but doesn't return $b = true
or $b = false;
. idea how make function work assigning $b
boolean rather writing '==1'
or '==0'
?
the problem in echo commented. if want check if variable either true or false should use
var_dump($variable)
instead of
echo $variable;
Comments
Post a Comment