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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -