|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41939 Bizarre behaviour testing a variable
Submitted: 2007-07-09 14:38 UTC Modified: 2007-07-09 14:58 UTC
From: steve at tequilasolutions dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.2.3 OS: FC4
Private report: No CVE-ID: None
 [2007-07-09 14:38 UTC] steve at tequilasolutions dot com
I have a variable set to 0.

if ($var=="on") returns true!!

This behaviour is not there in php4

Reproduce code:
admin@ds1009# php -v
PHP 4.3.11 (cgi) (built: Jun 16 2005 17:25:40)
Copyright (c) 1997-2004 The PHP Group

admin@ds1009# php
        $val = 0;
        if ($val=="on") print "on\n";
admin@ds1009# php5
        $val = 0;
        if ($val=="on") print "on\n";
admin@ds1009# php5
        $var = 0;
        if ($var=='anything') print "anything";

This bug is also in PHP/5.0.4 and may have been there since then.


Expected result:
0 should not equal 'on' or 'anything' 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-09 14:58 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 23:01:30 2024 UTC