Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP operator

Posted on 2006-10-25
6
Medium Priority
?
213 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
4 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 400 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…
Suggested Courses

877 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