|
Posted by Rob Wilkerson on 12/02/07 02:30
I'm attempting to do some work around existing code that uses bitwise
operations to manage flags passed into a function and I'm quite
frankly unequipped to do so. I've never done much with bitwise
operations and all the reading I've done today doesn't appear to be
helping me much. I'm hoping someone here can provide a remedial
lesson. Given the following constants:
define('FLAG_1, 1);
define('FLAG_2', 2);
define('FLAG_3', 4);
define('FLAG_4', 8);
define('FLAG_5', 16);
define('FLAG_6', 32);
define('FLAG_7', 64);
define('FLAG_8', 128);
define('FLAG_9', 256);
define('FLAG_10', 512);
define('FLAG_11', 1024);
define('FLAG_12', 2048);
I'm making this call:
$foo = my_function ( 'arg1', 'arg2', FLAG_1|FLAG_6|FLAG_4 );
To this function signature:
function my_function ( $arg1, $arg2='blah', $flags=NULL )
Inside the function, if I just echo the value of $args I get "41".
Is that correct? From my reading, it doesn't seem correct, but it may
just be my ignorance in this area. Any assistance reading and
understanding this stuff would be much appreciated.
Thanks.
Rob
[Back to original message]
|