|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14942 Logical bitwise operator not functioning correctly
Submitted: 2002-01-08 22:21 UTC Modified: 2002-01-09 00:47 UTC
From: mchiba at cisco dot com Assigned:
Status: Closed Package: Variables related
PHP Version: 4.0.6 OS: Linux Redhat 7.2
Private report: No CVE-ID: None
 [2002-01-08 22:21 UTC] mchiba at cisco dot com
I have two variables that I am trying to logically 'AND' in a bitwise fashion.  This does not work correctly if one of the variables is initialized to 0xffffffff.

ie if $field and $flags are two variables:

$flags = 0xffffffff;
$field = 0x01;

($flags & $field)? $str = "TRUE" : $str = "FALSE";

echo "$str <br>";

This prints 'FALSE' instead of 'True'!!  I tried debugging it with different values and it seems that if the highest bit is set then the it does the wrong thing.  ie. if $flags is instead initialized to 0x7fffffff then everything works fine!

Here is phpinfo on my system:


PHP Version 4.0.6

System Linux 2.4.5-7smp #1 SMP Tue Jun 26 14:19:49 EDT 2001 i686 unknown
Build Date Aug 27 2001
Configure Command  './configure' 'i386-redhat-linux' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--prefix=/usr' '--with-config-file-path=/etc' '--disable-debug' '--enable-pic' '--disable-rpath' '--enable-inline-optimization' '--with-apxs=/usr/sbin/apxs' '--with-bz2' '--with-curl' '--with-db3' '--with-dom' '--with-exec-dir=/usr/bin' '--with-gd' '--with-gdbm' '--with-gettext' '--with-jpeg-dir=/usr' '--with-mm' '--with-openssl' '--with-png' '--with-regex=system' '--with-ttf' '--with-zlib' '--with-layout=GNU' '--enable-debugger' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-yp' '--enable-wddx' '--without-mysql' '--without-unixODBC' '--without-oracle' '--without-oci8' '--with-pspell' '--with-xml'
Server API Apache
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php.ini
ZEND_DEBUG disabled
Thread Safety disabled

[Zend logo] This program makes use of the Zend scripting language engine:
Zend Engine v1.0.6, Copyright (c) 1998-2001 Zend Technologies


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-09 00:47 UTC]
This is fixed in > 4.0.6.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 27 20:03:37 2021 UTC