ID: 39954
Updated by: [EMAIL PROTECTED]
Reported By: olafvdspek at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Windows XP
PHP Version: 5.2.0
New Comment:
Yes, it does not convert strings to numbers and this is by design. It
actualy runs the "bitwise not" operator on each character of the
string.
Previous Comments:
------------------------------------------------------------------------
[2006-12-26 15:39:45] olafvdspek at gmail dot com
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 this bug report at http://bugs.php.net/?id=39954&edit=1