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

  • Home
  • SEARCH
  • 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 8020783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:47:17+00:00 2026-06-04T21:47:17+00:00

I understand there is assigning by reference ( $b = &$a ) and passing

  • 0

I understand there is assigning by reference ($b = &$a) and passing a variable by reference function foo( &$var )

I don’t understand how this works: return($var & 1) & return(!($var & 1)) ? I saw this fragment here.

<?php

    function odd($var)
    {
        // returns whether the input integer is odd
        return($var & 1);
    }

    function even($var)
    {
        // returns whether the input integer is even
        return(!($var & 1));
    }

    $array1 = array(1, 2, 3, 4, 5);
    $array2 = array(6, 7, 8, 9, 10, 11, 12);

    print_r(array_filter($array1, "odd"));
    // Array ( [0] => 1 [2] => 3 [4] => 5 ) //1,3,5 ..odd

    echo "<br>";

    print_r(array_filter($array2, "even")); 
    //Array ( [0] => 6 [2] => 8 [4] => 10 [6] => 12 ) 6,8,10,12...even

    // I tested with these variables
    echo "<br><br>";

    $var=22;

    echo(odd($var));     //prints 0
    var_dump(odd($var)); //int 0


    $var=11;

    echo (even($var));   //prints nothing
    var_dump(even($var));//boolean false

?> 
  • 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-04T21:47:18+00:00Added an answer on June 4, 2026 at 9:47 pm

    & is a bitwise “and” here, not a reference operator. & 1 checks whether the least significant bit it set. For odd numbers it is set, for even numbers it isn’t.

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

Sidebar

Related Questions

I understand that there are better ways to do what I'm attempting, but this
I don't understand why there is no inheritance in Java annotations, just as Java
I'm trying to understand the importance of initializing a variable, before assigning a value
I understand there is a limit to the number of requests per day using
So I understand there are many free image rotators, etc, out there using things
I've read a few threads here and I understand there's a scope issue with
I understand that there may be other questions regarding vanity urls but everyone i
I understand that there are many existing questions about Django template images, but I
I understand that there is a setting in Sun JVM for dumping the heap
Are there overall rules/guidelines for what makes a method thread-safe? I understand that there

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.