php5: string comparison operators fail if string starts with 0x

Allan Clements spam at exploding-planet.com
Tue Feb 17 13:46:18 UTC 2009


Package: php5
Version: 5.2.6-2ubuntu4.1
Severity: important


The operators == and != appear to fail if the string being compared starts with 0x

Using an example:

<?php
$a = "0xF14067C1C600003D";
$b = $a; // $b is now equal to $a

if ($a == $b){ // $a should be equal to $b
        echo "pass";
}else {
        echo "fail";
}
?>

Expected behaviour is that "pass" is printed.
However "fail" is printed in under 5.2.6 in ubuntu/debian.

The length of the string after the 0x also seems to matter (removing the latter half of the string will make it work correctly).

I have tested it on an older version of php under debian and with version 5.2.6 under windows and the example
above behaves correctly. It seems to be a problem specific to 5.2.6 under ubuntu/debian.

Using string comparison functions instead of the standard operators works as expected.


-- System Information:
Debian Release: lenny/sid
  APT prefers intrepid-updates
  APT policy: (500, 'intrepid-updates'), (500, 'intrepid-security'), (500, 'intrepid')
Architecture: i386 (i686)

Kernel: Linux 2.6.27-9-generic (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages php5 depends on:
ii  libapache2-mod-php5     5.2.6-2ubuntu4.1 server-side, HTML-embedded scripti
ii  php5-cgi                5.2.6-2ubuntu4.1 server-side, HTML-embedded scripti
ii  php5-common             5.2.6-2ubuntu4.1 Common files for packages built fr

php5 recommends no packages.

-- no debconf information




More information about the ubuntu-users mailing list