I have the most basic of problems. I was able to resolve it but it bugs me. I am trying to make sure that booleans are always reduced to 0 or 1 for the purposes of storage in mysql.
if ( ($bool === false || $bool === "false" || $bool == "false" || $bool == 0))
$bool = 0;
else
$bool = 1;
if "true" gets passed as a string $bool is assigned to 0. I don't get that. Below is the fix that I made. But it doesn't make any sense to me why I need it. I am relatively new to PHP but I keep getting hung up on little things like this.
if( ($bool === false || $bool === "false" || $bool == "false" || $bool == 0) && $bool != "true" )
$bool = 0;
else
$bool = 1;
I really want to know why the one at the top fails.
Thanks for looking at this.
Robert