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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:36:02+00:00 2026-05-20T04:36:02+00:00

Alright so I’ve already created a PHP bug about this but it was marked

  • 0

Alright so I’ve already created a PHP bug about this but it was marked as bogus, but I can’t help but to believe they didn’t read it carefully…

Link to Bug #54042

The error is caused by using an include() statement in an IF statement, making the statement believe it’s been passed an empty string.

Reviewing the bug will explain everything, including a test script.

Is it a bug, or am I missing something “feature”-wise? This is weird seeing as how assigning the output of include to a variable and then testing that value works just fine (which would be the workaround).

  • 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-20T04:36:03+00:00Added an answer on May 20, 2026 at 4:36 am

    Well, the documentation says:

    Because include() is a special language construct, parentheses are not needed around its argument. Take care when comparing return value.

    <?php
    // won't work, evaluated as include(('vars.php') == 'OK'), i.e. include('')
    if (include('vars.php') == 'OK') {
        echo 'OK';
    }
    
    // works
    if ((include 'vars.php') == 'OK') {
        echo 'OK';
    }
    ?>
    

    So this behaviour is already known and not considered as a bug. You even have an explanation why it works this way:

    include does not need parenthesis, so PHP does not really whether you want to do:

    include('vars.php') 
    

    or

    include(('vars.php') == 'OK')
    

    It seems that it is implemented to interpet it as the latter (something like the longest possible match).

    Same goes for

    $v = include('foo') . 'bar';
    

    which PHP interprets as

    $v = include(('foo') . 'bar');
    

    and tries to load foobar.

    But the solution is also given: Wrap the whole include statement into parenthesis, then there is only one way how PHP can interpret the call:

    $v = (include ('foo')) . 'bar';
    

    (Maybe) off topic: You will find similar “issues” in other parts of PHP. Take variable variables:

    $obj->$foo['bar'];
    

    PHP does not know whether you want to access the bar element of the array $foo and use this value as property name:

    $obj->{$foo['bar']};
    

    or if you want to access the bar element of $obj->$foo:

    {$obj->$foo}['bar'];
    

    In all these cases, there is a default behaviour of the parser. The developers decided for one possibility because they had to. It might not be what you expect, but if you know it, you can deal with it.

    This behaviour cannot simply be changed as it might break code that relies on this behaviour.

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

Sidebar

Related Questions

Alright I've been trying to find an answer to this for hours already but
Alright, hoping someone can help. I've got a page used to search for employees.
Alright I am trying to set up an OAuth Provider in PHP, but I
Alright. Hopefully this will be my last post about the download manager I am
Alright, I am so close to finishing this I can taste it. Over the
Alright, I'm trying to figure out why I can't understand how to do this
Alright, i've played around with this for over a week now and I can't
Alright, I am not entirely sure if I will explain this sufficiently, but here
Alright, I hope I can phrase this in a way that makes sense. If
Alright. So I figure it's about time I get into unit testing, since everyone's

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.