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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fuf at fuf dot sh dot cvut dot cz
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 20:01:36 2025 UTC