The examples in the online manual indicate that it is ok to use
the value of a variable for the file name:

        http://www.php.net/manual/en/function.include.php

it also shows examples without the parentheses.

Looks like (yet another) PHP bug to me.

Maybe someone more knowledgeable can comment.

> -----Original Message-----
> From: Henry [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 11, 2002 9:45 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] include_once("blah"); vs $blah="blah";
> include($blah);
>
>
> No, the line number is just of the line in the
> includING file of the
> include_once statement.
>
> It's very odd, is this a known limitation of PHP i..e.
> includes cannot have
> variable or functional file names.
>
> i.e.
>
> It's ok to do
> include_once("include/reallyimportantstuff.php");
>
> But it's not ok to do any of the following:
>
> 1)
> $filename="include/reallyimportantstuff.php";
> include_once($filename);
>
> 2)
> include_once("include"."/reallyimportantstuff.php");
>
> 3)
> $root="include";
> include_once($root."/reallyimportantstuff.php");
>
> ?????
>
>
> Henry
>
>
> "Jonathan Rosenberg" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Hmmm ... does the line number in the error message point to
> > something in the includeD file?  I.e., might you
> have some error
> > in the file you are including?
> >
> > > -----Original Message-----
> > > From: Henry [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, June 11, 2002 9:11 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [PHP] include_once("blah"); vs $blah="blah";
> > > include($blah);
> > >
> > >
> > > I did as you suggest with an interesting result:
> > >
> > > include_once "blah.php";
> > >
> > > worked
> > >
> > > var $blah="blah.php";
> > > include_once $blah;
> > >
> > > gave the following error:
> > >
> > > Parse error: parse error in <including file> on line
> > > <line number>
> > >
> > >
> > > Where the <including file> is the file that was doing
> > > the include!
> > >
> > >
> > >
> > > Previously include_once($blah) just messed up the
> > > scoping and global vars!
> > >
> > > Henry
> > >
> > > "Jonathan Rosenberg" <[EMAIL PROTECTED]> wrote in message
> > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > Out of curiosity, try
> > > >
> > > > <?php
> > > > global $root;
> > > > $blah="include\blah.php";
> > > > include_once $blah;
> > > > ?>
> > > >
> > > > & see if it behaves differently (i.e., no parens
> around the
> > > > include file name).
> > > >
> > > > > -----Original Message-----
> > > > > From: Henry [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Tuesday, June 11, 2002 8:15 AM
> > > > > To: [EMAIL PROTECTED]
> > > > > Subject: [PHP] include_once("blah"); vs $blah="blah";
> > > > > include($blah);
> > > > >
> > > > >
> > > > > My web hosting company is running  php 4.0.4pl1
> > > > >
> > > > > Why should it be that these are different
> > > > >
> > > > > <?php
> > > > >
> > > > > global $root;
> > > > > include_once("include\blah.php");
> > > > >
> > > > > ?>
> > > > >
> > > > > and
> > > > >
> > > > > <?php
> > > > >
> > > > > global $root;
> > > > > $blah="include\blah.php";
> > > > > include_once($blah);
> > > > >
> > > > > ?>
> > > > >
> > > > > When I say different I mean;
> > > > >
> > > > > 1) global variable are not avaiable in the
> second version
> > > > > 2) functions defined in the included file are not
> > > > > accessable in the
> > > > > including file.
> > > > > 3) in both examples the file is included, its just the
> > > > > scope that seem shot
> > > > >
> > > > > Any answers?
> > > > >
> > > > > Henry
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > PHP General Mailing List (http://www.php.net/)
> > > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to