ID: 15438
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Scripting Engine problem
Operating System: FreeBSD/Linux
-PHP Version: 4.1.1 and 4.2.3
+PHP Version: 4CVS-2002-10-14
New Comment:
> Updated Version
The include*/require* functions are a bit inconsistent.
In the simple tests done, the filename printed after "Running" is the
statement included in the source and executed by PHP, e.g.
var_dump(require("file2include"));
Every script ran exeutes the same statement twice in a row.
First tests done by including the following:
--> Running include.php
File got included
int(1)
File got included
int(1)
--> Running include_once.php
File got included
int(1)
bool(true)
--> Running require.php
File got included
UNKNOWN:0
File got included
UNKNOWN:0
--> Running require_once.php
File got included
int(1)
bool(true)
Same tests ran with:
--> Running include.php
File got included
string(18) "Returning a string"
File got included
string(18) "Returning a string"
--> Running include_once.php
File got included
string(18) "Returning a string"
bool(true)
--> Running require.php
File got included
UNKNOWN:0
File got included
UNKNOWN:0
--> Running require_once.php
File got included
string(18) "Returning a string"
bool(true)
Previous Comments:
[2002-10-08 06:29:23] [EMAIL PROTECTED]
confirmed with 4.4.0-dev (cli)/ ZE 1.4.0. i'm including a repro recipe
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# foo.php
# bar.inc
#
echo x - foo.php
sed 's/^X//' >foo.php << 'END-of-foo.php'
X#!/usr/bin/env php
Xbar.inc << 'END-of-bar.inc'
X
The code above returns this fatal error:
Warning: Failed opening '1' for inclusion
(include_path='.:/usr/local/lib/php') in
/usr/local/apache/htdocs/test.php on line 2
And now i do it the longer way:
Works perfectly
And another way that works:
The problem really seems what [EMAIL PROTECTED] said, a scripting engine
bug.
PS. Your reply about me asking a support question here is rather weird
to me, i was just reporting a bug..
[2002-10-07 22:17:06] [EMAIL PROTECTED]
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php
Thank you for your interest in PHP.
You can only check if include/include_once failed or succeeded if the
included file returns a value. This is clearly documented at:
http://www.php.net/manual/en/function.include.php
[2002-02-09 06:17:06] [EMAIL PROTECTED]
I'm not sure this is actually a bug. I gather the returned value from
an include is the one you specify in the included file with 'return
$var'
Read more at http://www.php.net/manual/en/function.include.php about
return() in included files.
If you want to evaluate if an include was succesfull you could add:
$var = true;
return $var
at the end of the included file, but this should also do the trick:
((int) @include_once("../lib/test.php")) or die("Don't exist");
which is probably just a check if there's some warning text just like
michael already demonstrated.
[2002-02-08 10:51:58] [EMAIL PROTECTED]
Actually you can check if an include failed or not like this, but I
think the parser gets confused if you use the '== false'.
Making this a scripting engine problem.
Derick
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/15438
--
Edit this bug report at http://bugs.php.net/?id=15438&edit=1