php.net |  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
Votes:1
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: trevorjohns at google dot com
New email:
PHP Version: OS:

 

 [2009-06-25 00:40 UTC] trevorjohns at google dot com
Description:
------------
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.

Note:
This was discovered while I was investigating the following downstream 
bug in Zend Framework: http://framework.zend.com/issues/browse/ZF-7107.

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
var_dump(include('input.php'));

# main.php (mirrors above input)
<?php
var_dump(include('input.php'));

# input.php
<?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'));
int(1)

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-21 13:01 UTC] jani@php.net
See also bug #49000
 [2009-07-30 05:03 UTC] stas@php.net
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

<?php
var_dump(include('input.php'));
int(1))
 [2009-08-05 21:49 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

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-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 08:01:29 2024 UTC