Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7955 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15935 invoked by uid 1010); 18 Feb 2004 14:53:39 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 15911 invoked by uid 1007); 18 Feb 2004 14:53:39 -0000 To: internals@lists.php.net, hartmut@php-groupies.de Date: Wed, 18 Feb 2004 15:53:36 +0100 Message-ID: <20040218155336.0095e875@localhost.localdomain> In-Reply-To: <40337A3A.8040308@php.net> References: <20040218152756.1f958513@localhost.localdomain> <40337A3A.8040308@php.net> Organization: Freelancer X-Newsreader: Sylpheed version 0.9.8claws (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Posted-By: 213.196.192.45 Subject: Re: [PHP-DEV] HEAD, include(_once), bug in variable declaration From: paj@pearfr.org (Pierre-Alain Joye) On Wed, 18 Feb 2004 15:44:10 +0100 hartmut@php.net (Hartmut Holzgraefe) wrote: > it works for the first call to getFoo(), > on any following call include_once > will ignore "inc.php" as it was already > included before, and as $foo is a local > variable to getFoo() it won't exist in > any but the first call > > remember that in PHP include is evaluated > at runtime, not at compile time ... Thanks for the reminder :) I thought about that at the first source of the problem, but: It works with php4. For instance this is widely used to include a given file on demand, and only on demand. I thought that in the context of getFoo (lost between 2 calls), it should include it again. In this simple case, it is not a problem, there is no global "pollution". But in the case the included files contains a class/function definition, you run in troubles. That's why I think the behavioir should remain the same as with php4. An alternative is to split all possible runtime datas to a different file and not in the same file as the class/function declaration. But in both cases that will break a lot of scripts around. hth pierre