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 6628201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:06:11+00:00 2026-05-25T22:06:11+00:00

Possible Duplicate: Reference – What does this symbol mean in PHP? I googled much

  • 0

Possible Duplicate:
Reference – What does this symbol mean in PHP?

I googled much for finding answer but i couldn’t find any.
I saw in few free source codes that they use “|” sign to combine values or something. can someone enlighten what is different between “|” and “+”?

sample:

<?php
define('PERMISSION_DENIED', 0);
define('PERMISSION_READ', 1);
define('PERMISSION_ADD',  2);
define('PERMISSION_UPDATE', 4);
define('PERMISSION_DELETE', 8);


$read_only = PERMISSION_READ;
$read_delete = PERMISSION_READ | PERMISSION_DELETE;
$full_rights = PERMISSION_DENIED | PERMISSION_READ | PERMISSION_ADD | PERMISSION_UPDATE | PERMISSION_DELETE;


$myrights = PERMISSION_READ;
$myrights |= PERMISSION_UPDATE; 
?>

why not just:

<?php
define('PERMISSION_DENIED', 0);
define('PERMISSION_READ', 1);
define('PERMISSION_ADD',  2);
define('PERMISSION_UPDATE', 4);
define('PERMISSION_DELETE', 8);


$read_only = PERMISSION_READ;
$read_delete = PERMISSION_READ + PERMISSION_DELETE;
$full_rights = PERMISSION_DENIED + PERMISSION_READ + PERMISSION_ADD + PERMISSION_UPDATE + PERMISSION_DELETE;


$myrights = PERMISSION_READ;
$myrights += PERMISSION_UPDATE; 
?>
  • 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-05-25T22:06:11+00:00Added an answer on May 25, 2026 at 10:06 pm

    it’s the bitwise or operator, so you’re operating with numbers in base 2 notation.

    for example:

    1000 | 0001 = 1001 ==> (8 | 1 = 9)

    http://www.php.net/manual/en/language.operators.bitwise.php

    In your code each permission is represented by one bit in a different position, I mean:

    1 = 0001 = perm1
    2 = 0010 = perm2
    4 = 0100 = perm3
    8 = 1000 = perm4

    so doing or with those numbers gives you the number with all the permissions together. then if you wanna check if a permission is set you gotta do an and operation with the permission that you’re checking, for example:

    $user_perms = perm1 | perm3;
    if ($user_perms & perm4) echo "user does not have this permission";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Reference - What does this symbol mean in PHP? I was wondering
Possible Duplicate: Reference - What does this symbol mean in PHP? Is there any
Possible Duplicate: Reference - What does this symbol mean in PHP? I've been doing
Possible Duplicate: Reference - What does this symbol mean in PHP? What does the
Possible Duplicate: Reference - What does this symbol mean in PHP? I'm making a
Possible Duplicate: Reference - What does this symbol mean in PHP? What is the
Possible Duplicate: Reference - What does this symbol mean in PHP? The third line
Possible Duplicate: Reference - What does this symbol mean in PHP? Hi, I was
Possible Duplicate: Reference - What does this symbol mean in PHP? I've been programming
Possible Duplicate: Reference - What does this symbol mean in PHP? What exactly does

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.