Re: include_once() return values ?
| From: | Stig Sæther Bakken | Date: | Fri, 28 Jul 2000 06:56:37 +0000 |
| Subject: | Re: include_once() return values ? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-26664@lists.php.net to get a copy of this message | ||
Alan wrote:
>
> Hi All,
>
> Question: what would you expect include_once() to return on the second attempt to include the
> same file?
>
> On the first attempt it behaves like include(), returning the return value of the included
> file, or the int(1) if there is no return statement in the included file.
>
> At the moment include_once() always returns NULL on the second attempt so defensive coding like
> this wont work:
>
> if(!@include_once("$somefile"){
> // handle failled include attempt
> }
>
> ( note that this example is based on ideas implemented in pear DB::connect() )
>
> Is this intentional (feature request material) or bug report time ?
(FYI: DB::factory() and DB::connect() don't do this anymore.)
But I agree with you, the return value if the file was already included
should be true. This is what I would expect, and it is consistent with
include.
- Stig