Re: Name of file currently being processed
| From: | Joey Smith | Date: | Tue, 18 Jul 2000 04:31:34 +0000 |
| Subject: | Re: Name of file currently being processed | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-24842@lists.php.net to get a copy of this message | ||
But PHP should not (IMHO) crash on
p1.php
<?
include "p1.php";
?>
It seems the easiest way to do this is to make sure we are not including
ourselves. It won't stop recursive dep/ completely, but at lest at the
top-level, with (what seems to be) negligible cost.
On Tue, 18 Jul 2000, Adam Trachtenberg wrote the following to Joey Smith :
> include_once()
>
> -adam
>
> On Mon, 17 Jul 2000, Joey Smith wrote:
>
> > Actually, I asked the wrong question...I don't really want to do this from
> > user-space (although if the mechanism is there, it might be useful in
> > user-space), what I am really looking to do is to protect from recursive
> > inclusion of files:
> >
> > p1.php
> > <?
> > include "p1.php";
> > ?>
> >
> > Yes, I realize, this is a stupid error...but it seems like it might not be
> > too hard to catch...
> >
> > main/main.c:497 (or so)
> > if (filename == current_file)
> > RETURN_FALSE;
> >
> >
> >
> > On Mon, 17 Jul 2000, Joey Smith wrote the following to PHP Developer List :
> >
> > > Is there any way to find out the name of the file currently being
> > > processed? For example:
> > >
> > > p1.php
> > > <?php
> > > include "p2.php";
> > > ?>
> > >
> > > p2.php
> > > <?php
> > > include "p3.php";
> > >
> > > print current_file();
> > > ?>
> > >
> > > p3.php
> > > <?php
> > > print current_file();
> > > ?>
> > >
> > > Hitting p1.php would print:
> > > p3.php
> > > p2.php
> > >
> > >
> > >
> >
> >
> > --
> > PHP Development Mailing List <http://www.php.net/>
> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-dev-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
>
>