#48682 [Opn->Fbk]: include() ignores return value when running in interactive shell
| From: | jani@php.net | Date: | Wed, 05 Aug 2009 21:49:15 +0000 |
| Subject: | #48682 [Opn->Fbk]: include() ignores return value when running in interactive shell | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-140698@lists.php.net to get a copy of this message | ||
ID: 48682
Updated by: jani@php.net
Reported By: trevorjohns at google dot com
-Status: Open
+Status: Feedback
Bug Type: Scripting Engine problem
Operating System: Mac OS X 10.5.8 / Arch Linux
PHP Version: 5.2.10
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2009-07-30 15:09:04] 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-07-30 05:03:20] stas@php.net
Works for me in 5.3. Does it work for you with current 5.3?
------------------------------------------------------------------------
[2009-07-21 13:01:11] jani@php.net
See also bug #49000
------------------------------------------------------------------------
[2009-06-25 00:40:52] 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!"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48682&edit=1