php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3922 == bug
Submitted: 2000-03-25 02:14 UTC Modified: 2000-05-20 04:33 UTC
From: fuf at fuf dot sh dot cvut dot cz Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.15 OS: linux 2.2.14pre16 etc
Private report: No CVE-ID: None
 [2000-03-25 02:14 UTC] fuf at fuf dot sh dot cvut dot cz
the following program IMO misbehaves (tested on php 3.0.12 and php-4.0b4pl1):
<?
	$var = 0;
	if($var == 'N/A')
		echo "PHP claims \$var is 'N/A', actual \$var's value is $var\n";
	else
		echo "this version of PHP is ok\n";
?>

note that when the value of $var is non-zero all is okay. i guess that's a bug and not a feature.

	regards,
			fuf

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-20 02:40 UTC] hholzgra at cvs dot php dot net
it's not a bug, it's a feature :( (same in php4)

you compare an integer to a string,
the string is converted to an integer
and as 'N/A' does not contain any digits
its integer value is 0, so they are
equal
the other way round it wouldn't:

0 == 'N/A'   -> true
'N/A' == 0   -> false

or in php4 you could use '===' instead of '=='

rather missleading, maybe string->integer 
conversion should return something like
not-a-number instead of 0 in this case ?
 [2000-05-20 04:33 UTC] hholzgra at cvs dot php dot net
sorry

the other way round it's still the case

 0 == 'N/A'   -> true
 'N/A' == 0   -> true

confusing, ain't it
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 17:01:29 2024 UTC