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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:01:12+00:00 2026-05-23T06:01:12+00:00

Possible Duplicates: PHP – and / or keywords PHP shorthand syntax Quick question. I

  • 0

Possible Duplicates:
PHP – and / or keywords
PHP shorthand syntax

Quick question. I keep seeing shorthand expressions in libraries around the place, and despite having been a PHP developer for over 3 years, I struggle to quite see how the following would evaluate.

What exactly does the PHP interpreter do with the following shorthand lines of code when it encounters them?

<?php
    defined('foo') OR exit('foo is not defined!');

    $foo AND $this->bar();

I’m guessing that it’ obviously conditional execution – i.e. the second statement won’t get executed unless the first bit is true… but the use of the bitwise operators confuse me a bit.

Can someone elaborate?

Thanks 🙂

  • 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-23T06:01:13+00:00Added an answer on May 23, 2026 at 6:01 am

    Back when I was learning PHP I remember reading the ‘do or die’ style commands and not fully understanding them at the time, the classic example is:

    mysql_connect() or die('couldn\'t connect');
    

    Bear in mind that the conditions will only run if they’re required, for example:

    if (a == b && b == c)
    

    Here b == c will only be tested if a == b. The same theory applies to or:

    if (a == b || b == c)
    

    Now b == c will only be tested if a != b.

    In this case you are relying on this order to run a command (exit or $this->bar()) in certain conditions.

    Be Aware… exit() is a bad idea in this circumstance – if you exit(‘something went wrong’) there’s nothing anyone can do to hide this error from the user, also it’s likely to issue a 200 OK HTTP status where a 500 Internal Server Error would be much more appropriate, I would consider something more like:

    defined('foo') OR throw new Exception('foo is not defined!');
    

    Here you have a chance to either catch the Exception or at least let PHP catch it and issue a 500 status.

    Mat

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

Sidebar

Related Questions

Possible Duplicates: How can I convert ereg expressions to preg in PHP? What is
Possible Duplicates: Checking for a valid url using Javascript Regular Expressions PHP validation/regex for
Possible Duplicates: Are PHP short tags acceptable to use? What does “<?=” mean when
Possible Duplicates: Create a webpage with Multilanguage in PHP PHP - how to translate
Possible Duplicates: What security issues should I look out for in PHP What should
Possible Duplicates: How do I extract HTML content using Regex in PHP RegEx match
Possible Duplicate: PHP: different quotes? Simple question: What is the difference between ' and
Possible Duplicates: iPhone: Post data to php page Passing Data From iPhone app to
Possible Duplicates: What is the difference between the PHP open tags <?= and <?php/<??
Possible Duplicates: Reference - What does this symbol mean in PHP? what do “=&”

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.