Solved

PHP operator

Posted on 2006-10-25
6
204 Views
Last Modified: 2006-12-28
I'm reading an ebook, it mention about those operators:
^=, &=, |=, <<=, >>=

Can anyone tell me what they are?
Thank in advanced
0
Comment
Question by:tunglam
  • 2
6 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 17804151
Those are bitwise operators

$a &= $b is the same as $a = $a & $b (bitwise and)
$a |= $b is the same as $a = $a | $b (bitwise or)

$a <<= 2 is the same as $a = $a << 2 (leftshifting bits)

(leftshifting 2 bits is the same as multiplying by 4, 3 bits is times 8, 4 bits, times 16, etc).

-r-
0
 

Author Comment

by:tunglam
ID: 17811973
Can you what is bitwise operators?
What are they for? And give me some example? Thank you!
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 100 total points
ID: 17812021
Bitwise operators work on binairy forms of data (the zero's and one's.)

So 2 & 3 equals in binairy code 0010 && 0011 => 0010 (only the second one from the right is in both binairy

0101 << 1 is the same as putting all zero's and one's one position to the left: 1010
0101 << 3: 1000
0101 >> 1: (shift to right) 0010
0101 >> 3: 0001

See also: http://nl3.php.net/manual/en/language.operators.bitwise.php

-r-
0
 
LVL 2

Expert Comment

by:_delas
ID: 17942008
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question