From: olafvdspek at gmail dot com
Operating system: Windows XP
PHP version: 5.2.0
PHP Bug Type: Scripting Engine problem
Bug description: ~ operator doesn't convert string to integer first
Description:
------------
The ~ operator doesn't appear to convert a string to an integer first,
like most other operators do. This produces unexpected results of course.
Reproduce code:
---------------
$b = '0';
$b = ~$b;
printf('%s - %s<br>', $b, ord($b));
$b = 0;
$b = ~$b;
printf('%s - %s<br>', $b, ord($b));
Expected result:
----------------
-1 - 45
-1 - 45
Actual result:
--------------
Ï - 207
-1 - 45
--
Edit bug report at http://bugs.php.net/?id=39954&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39954&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39954&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39954&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39954&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39954&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39954&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39954&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39954&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39954&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39954&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39954&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39954&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39954&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39954&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39954&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39954&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39954&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39954&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39954&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39954&r=mysqlcfg