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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:42:33+00:00 2026-05-28T20:42:33+00:00

Javascript employs the conjunction and disjunction operators. The left–operand is returned if it can

  • 0

Javascript employs the conjunction and disjunction operators.

The left–operand is returned if it can be evaluated as: false, in the case of conjunction (a && b), or true, in the case of disjunction (a || b); otherwise the right–operand is returned.

Do equivalent operators exist in PHP?

  • 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-28T20:42:34+00:00Added an answer on May 28, 2026 at 8:42 pm

    PHP supports short-circuit evaluation, a little different from JavaScript’s conjunction. We often see the example (even if it isn’t good practice) of using short-circuit evaluation to test the result of a MySQL query in PHP:

    // mysql_query() returns false, so the OR condition (die()) is executed.
    $result = mysql_query("some faulty query") || die("Error");
    

    Note that short-circuit evaluation works when in PHP when there is an expression to be evaluated on either side of the boolean operator, which would produce a return value. It then executes the right side only if the left side is false. This is different from JavaScript:

    Simply doing:

    $a || $b
    

    would return a boolean value TRUE or FALSE if either is truthy or both are falsy. It would NOT return the value of $b if $a was falsy:

    $a = FALSE;
    $b = "I'm b";
    
    echo $a || $b;
    // Prints "1", not  "I'm b"
    

    So to answer the question, PHP will do a boolean comparison of the two values and return the result. It will not return the first truthy value of the two.

    More idiomatically in PHP (if there is such a thing as idiomatic PHP) would be to use a ternary operation:

    $c = $a ? $a : $b;
    
    // PHP 5.3 and later supports
    $c = $a ?: $b;
    echo $a ?: $b;
    // "I'm b"
    

    Update for PHP 7

    PHP 7 introduces the ?? null coalescing operator which can act as a closer approximation to conjunction. It’s especially helpful because it doesn’t require you to check isset() on the left operand’s array keys.

    $a = null;
    $b = 123;
    $c = $a ?? $b;
    // $c is 123;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Javascript is pretty shaky for me, and I can't seem to find the answer
Javascript can manipulate the document the browser is displaying, so the following: <script> document.write(<table><tr><td>Hola</td><td>Adios</td></tr></table>);
JavaScript can interact very well with the server also. Using Ajax we can send
Javascript functions can be declared on a objects prototype like this: <object name>.prototype.<variable name>=function(){
There are few webpage which employs some javascript/ajax calls to fill some fields in
JavaScript if ((valid1 && valid2 && valid3 && valid4 && valid5 && valid6 &&
JavaScript has two handy substring functions: substring(from,to) and substr(start,length) . This means I can
Why do some sites (or advertisers that give clients javascript code) employ a technique
JavaScript post request like a form submit shows you how to submit a form
JavaScript allows functions to be treated as objects--if you first define a variable as

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.