This is absolute insanity. I was testing a post variable today that should always evaluate to a single character. Example code is...
if($_POST['status'] == '' || $_POST['status'] == 0){ die('oh no!'); }
If I pass a status of P, it was executing the die statement. I then created a PHP file with the following code...
echo 'P1: '.intval($_POST['status']=='').'<br />';
echo 'P2: '.intval($_POST['status']==0).'<br />';
echo 'P3: '.intval('P'==0).'<br />';
Guess what? P2 & P3 both evaluate to TRUE. The intval is there just to show 0 instead of nothing on P1.
Is this a known bug of PHP? Is this just something that is broken on the version I am running? Frankly, I'm at a complete loss as to why it is doing this. It evaluates correctly using triple equals, but not on double. P definitely doesn't equal 0 in my book...