Return values from include/require (Was: Re: [PHP-DEV] Bug #14165 Updated: No way to return variables from remote include())
| From: | Markus Fischer | Date: | Wed, 21 Nov 2001 23:12:40 +0000 |
| Subject: | Return values from include/require (Was: Re: [PHP-DEV] Bug #14165 Updated: No way to return variables from remote include()) | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-71330@lists.php.net to get a copy of this message | ||
On Wed, Nov 21, 2001 at 10:01:34PM -0000, sniper@php.net wrote :
> ID: 14165
> Updated by: sniper
> Reported By: steve@petabit.com
> Status: Bogus
> Bug Type: Feature/Change Request
> Operating System: Linux
> PHP Version: 4.0.5
> New Comment:
>
> Maybe if you added some example script here (which you think
> should work) we might understand what you mean?
>
> And note that include/require don't return anything.
> They are language constructs, not functions.
Those function do return values. However, 'require' seems to
have a problem.
File a.php:
<?php
?>
(i.e., it is empty)
File b.php
Test 1:
<?php $foo = include 'a.php'; var_dump($foo);?>
outputs
php -f b.php
int(1)
Test 2:
<?php $foo = include_once 'a.php'; var_dump($foo); ?>
outputs
php -f b.php
int(1)
Test 3:
<?php $foo = require 'a.php'; var_dump($foo); ?>
outputs
php -f b.php
UNKNOWN:0
Test 4:
<?php $foo = require_once 'a.php'; var_dump($foo); ?>
outputs
php -f b.php
int(1)
Further testing showed that include, include_once and
require_once behaved the same in terms of return values. The
all returned the
return "return_value";
when using file a.php with <? return "return_value"; ?>
in $foo. However, require still returns UNKNOWN:0
This was tested with RC3 and CVS on debian linux (also on
two different machines). However, when I asked someone else
he reported that 'require' on freebsd also returned int(1).
I'm using no php.ini file.
Can somone run this tests too on same/other machines?
- Markus