#18680 [Ana->Csd]: Logical OR fails if value is a string

From: Date: Thu, 01 Apr 2004 08:16:36 +0000
Subject: #18680 [Ana->Csd]: Logical OR fails if value is a string
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969359868@lists.php.net to get a copy of this message
ID: 18680 Updated by: irchtml@php.net Reported By: su-php at bossi dot com -Status: Analyzed +Status: Closed Bug Type: Documentation problem Operating System: any PHP Version: 4.3.2-dev 5CVS-2003-03-10 New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2003-03-10 13:32:14] moriyoshi@php.net Should be a documentation problem for the sake of backwards compatibility, though I don't think this feature is useful anyhow. ------------------------------------------------------------------------ [2003-03-09 19:28:03] moriyoshi@php.net <?php var_dump(ord(chr(32) | chr(64))); var_dump(32 | 64); var_dump(ord(chr(127) & (chr(32) | chr(16)))); var_dump(127 & (32 | 16)); var_dump("ABC" | " bc"); // should result in "abc" ?> If a bitwise operation are performed between two string nodes, that ends up with the results of that operation of the values of each character's character codes. ------------------------------------------------------------------------ [2002-08-01 15:22:00] su-php at bossi dot com It is not a session related problem, but a string conversion problem. Below is a script which shows the problem. When doing test, remember that the values should be based on a power of two, that is: 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, ... ------------------------- <html><head></head><body> <h1>ORing Values</h1> <? do_table( 1, '1', 8, '8' ); do_table( 2, '2', 8, '8' ); do_table( 2, '2', 4, '4' ); do_table( 2, '2', 16, '16' ); do_table( 1, '1', 16, '16' ); ?> </body></html> <? function do_table( $val_1_num, $val_1_txt, $val_2_num, $val_2_txt ) { ?> <br> <table border="1"> <tr> <th></th> <th>Value 1</th> <th>Value 2</th> <th>Raw OR</th> <th>strval OR</th> <th>0+ OR</th> </tr> <tr> <td>Number</td> <td align="center"><?= $val_1_num ?></td> <td align="center"><?= $val_2_num ?></td> <td align="center"><?= $val_1_num | $val_2_num ?></td> <td align="center"></td> <td align="center"><?= (0 + $val_1_num) | (0 + $val_2_num) ?></td> </tr> <tr> <td>Text</td> <td align="center"><?= $val_1_txt ?></td> <td align="center"><?= $val_2_txt ?></td> <td align="center"><?= $val_1_txt | $val_2_txt ?></td> <td align="center"><?= strval($val_1_txt) | strval($val_2_txt) ?></td> <td align="center"><?= (0 + $val_1_txt) | (0 + $val_2_txt) ?></td> </tr> </table> <?}?> ------------------------- ------------------------------------------------------------------------ [2002-07-31 18:57:18] sniper@php.net Please add a short but COMPLETE example script which clearly demonstrates the problem. ------------------------------------------------------------------------ [2002-07-31 15:03:38] su-php at bossi dot com I stated that strval() does not work. However a kludge that DOES work is: echo "Val : ".((0 + $opt['time']) | (0 + $opt['date'])); ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/18680 -- Edit this bug report at http://bugs.php.net/?id=18680&edit=1

« previous php.doc (#969359868) next »