Jump to content

Bitwise operators on a Class instance


Buddski

Recommended Posts

Hey All,

Ive been coding PHP for a few years now but have never looked into Bitwise operators before..

I have picked up a few things but there is one part in particularly that sis bugging me..

 

I was reading a script and noticed this:

$Session =& new Session();

 

the Session class construct returns the session_id()

I was wondering if anybody could shed some light on how a bitwise operator such as this works in this context?

 

Link to comment
https://forums.phpfreaks.com/topic/184590-bitwise-operators-on-a-class-instance/
Share on other sites

this is how a bitwise operator works

consider a value , 3, in binary code, it is 00000011

and another value, 4, in vunary code, it is 00000100

 

if 3 &  4, then returns 0

00000011

00000100

you do the and  by each bit

for example, the right most bit, 1 (from 3), and 0 ( from 4), it is 0

2nd right most bit, 1 from 3, 0 from 4 is 0

3rd right most bit, 0 from 3, 1 from 4, is 0

and the rest is 0 too

Thanks for that link..

I was getting myself confused with =& and &=

I should learn to read better.

 

That link was exactly what I was looking for it had absolutley nothing to to with bitwise at all ::)

 

Thanks for clearing it all up..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.