Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7919505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:53:19+00:00 2026-06-03T15:53:19+00:00

IN php, how do the following operands work? ^ | e.g. $a = 11;

  • 0

IN php, how do the following operands work?

^
|

e.g. $a = 11;
$b = 7;
echo $a ^ $b;

outputs 12

and

    $a =    11;
$b =    7;
echo $a | $b;

outputs 15

Im not sure why in each case. Can someone please shed some light?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:53:20+00:00Added an answer on June 3, 2026 at 3:53 pm

    Those are bitwise XOR and OR.

    $a = 11; // 1011
    $b =  7; // 0111
    

    With XOR each bit that is different in $a and $b becomes a 1, the bits that are the same become a 0.

    $a ^ $b: // 1100 = 12
    

    With OR each bit that is a 1 in either $a or $b becomes a 1, in this case all the bits.

    $a | $b: // 1111 = 15
    

    There is also an AND equivalent: $a & $b: // 0011 = 3

    A full list of PHP’s bitwise operators.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following PHP code prints out this warning: Warning: openssl_csr_get_public_key(): supplied resource is not
I have the following php file: <html> <body> <?php echo test; ?> </body> </html>
I have following PHP if/else statement - how can I tell it to go
I have following PHP echo statement: echo <td><a href='delete-news.php?deleteID=.$id. onclick='return confirm('Really delete?');'>Delete</a></td>; which is
I have the following php: 1) echo json_encode(array('message' => 'Invalid Login Details: '.$user)); I
With following php preg_match i'm trying to show a error message if someone input
With following php code i can get total amount of debit columns from Mysql
I have following PHP script. I want to count and print comments for each
The following PHP code will output 3 . function main() { if (1) {
The following PHP code does exactly what I want to do. The problem is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.