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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:23:18+00:00 2026-06-15T15:23:18+00:00

Take for instance the following code: phpinfo(INFO_MODULES | INFO_ENVIRONMENT | INFO_VARIABLES); A single argument

  • 0

Take for instance the following code:

phpinfo(INFO_MODULES | INFO_ENVIRONMENT | INFO_VARIABLES);

A single argument is being used, but I am providing a list of options separated by a single pipe symbol.

  • What exactly is happening with the argument value in the function?
  • Can I use the same thing in my own functions?
  • Is so how, and are there benefits to this over say passing an array instead?
  • 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-15T15:23:19+00:00Added an answer on June 15, 2026 at 3:23 pm

    Bitwise operators

    Bitwise operators modify the bits of the values involved. A bitwise OR basically ORs together each bit of both the left and right argument. For example:

    5 | 2
    

    Would translate to bits/binary as:

    101 | 10
    

    Which would result in:

    111
    

    Because:

    1 || 0 = 1
    0 || 1 = 1
    1 || 0 = 1
    

    And as an Integer that is the representation of 7 which is exactly what you get if you:

    echo 5 | 2;
    

    In the words of Eddie Izzard… Flag!

    As Ignacio states, this is most often used in PHP (and other langauges) as a way to combine multiple flags. Each flag is usually defined as a constant whose value is normally set to an integer that represents just one bit at a different offset:

    define('FLAG_A', 1); /// 0001
    define('FLAG_B', 2); /// 0010
    define('FLAG_C', 4); /// 0100
    define('FLAG_D', 8); /// 1000
    

    Then when you OR these together they operate each on their own bit offset and will never collide:

    FLAG_A | FLAG_C
    

    Translates to:

    1 | 100
    

    So you end up turning on:

    101
    

    Which represents the integer 5.

    Then all the code has to do—the code that will be reacting to the different flags being set—is the following (using a bitwise AND):

    $combined_flags = FLAG_A | FLAG_C;
    
    if ( $combined_flags & FLAG_A ) {
      /// do something when FLAG_A is set
    }
    
    if ( $combined_flags & FLAG_B ) {
      /// this wont be reached with the current value of $combined_flags
    }
    
    if ( $combined_flags & FLAG_C ) {
      /// do something when FLAG_C is set
    }
    

    At the end of the day it just makes things easier to read by having named constants, and generally more optimal by relying on integer values rather than strings or arrays. Another benefit of using constants is that if they are ever mistyped when used, the compiler is in a better situation to tell and to throw a warning… if a string value is used it has no way of knowing that anything is wrong.

    define('MY_FLAG_WITH_EASY_TYPO', 1);
    
    my_function_that_expects_a_flag( MY_FLAG_WITH_EASY_TPYO );
    
    /// if you have strict errors on the above will trigger an error
    
    my_function_that_expects_a_flag( 'my_string_with_easy_tpyo' );
    
    /// the above is just a string, the compiler knows nowt with 
    /// regard to it's correctness, so instead you'd have to
    /// code your own checks.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written the following code but it doesn't give the correct result (for instance
Take for instance the following code for Edit action in my controller: // POST:
I've been told that every COM method callable from C++ code (take for instance
The following code is part of a WCF service. Will eventWatcher take up a
Let's take the following code: class Foo { string bar; public void Method() {
let's take the following code: class const_int { public: constexpr const_int(int data) : data_(data)
I have a string with url.Please take a look at the following code.I am
For instance, if I was to create the following code: a_list = ['this', 'is',
Take the following code written in Java: choice = keyboard.nextByte(); switch (choice) { case
I am using following code to get List from xml file - public static

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.