Solved

PHP operator

Posted on 2006-10-25
6
203 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP/Magento not logging 2 36
php date - compare 4 40
How can I upload multiple images from a HTML form? 2 18
.htaccess 5 12
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now