|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48682 include() ignores return value when running in interactive shell
Submitted: 2009-06-25 00:40 UTC Modified: 2009-08-13 01:00 UTC
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: trevorjohns at google dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.2.10 OS: Mac OS X 10.5.8 / Arch Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-06-25 00:40 UTC] trevorjohns at google dot com
The include() function is supposed to return the return value of 
whatever code is present in a specified file, or int(1) if no return 
value is produced.

However, when using the interactive shell (php -a), include() will 
always return int(1), assuming that the specified file was found.

This was discovered while I was investigating the following downstream 
bug in Zend Framework:

Also, this seems to be a duplicate of Bug #48056, but I can't find any 
explanation for why that bug was closed as bogus.

Reproduce code:
# Input to interactive shell

# main.php (mirrors above input)

# input.php
return "It works!";

Expected result:
$php -a
Interactive shell

php > var_dump(include('input.php'));
string(9) "It works!"

$php main.php
string(9) "It works!"

Actual result:
$php -a
Interactive shell

php > var_dump(include('input.php'));

$php main.php
string(9) "It works!"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-21 13:01 UTC]
See also bug #49000
 [2009-07-30 05:03 UTC]
Works for me in 5.3. Does it work for you with current 5.3?
 [2009-07-30 15:09 UTC] trevorjohns at google dot com
Nope, it's still behaving the same as before:

$ php --version
PHP 5.3.0 (cli) (built: Jul 21 2009 17:54:37) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

$ php -a
Interactive mode enabled

 [2009-08-05 21:49 UTC]
Please try using this snapshot:
For Windows:

Stas asked if it works 
 [2009-08-13 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Dec 03 20:01:28 2023 UTC