RE: how to get the absolute path of an included file?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27 April 2006 15:25, Brad Bonkoski wrote:

> Bing Du wrote:
> 
> > Hello,
> > 
> > Here are the two scripts.  The result is 'var is' rather than 'var
> > is foo'.  My suspect is I did not set the file path right in
> > 'include'.  So in file2.php, how should I get the actual absolute
> > path it really gets for file1.php?  Is it stored in some
> > environment variable or something?  I'd appreciate any help. 
> > 
> > file1.php
> > 
> > ==
> > <?php
> > $var = 'foo';
> > > 
> > ==
> > 
> > file2.php
> > 
> > ==
> > <?php
> > 
> > include '/some/path/file1.php';
> > 
> > 
> global $var; //you have to declare it as a global otherwise it will
> assume a local value 

Complete twaddle.  That only applies for functions.

This is likely to be, as Bing deduced, a path error on the include filename.

Bear in mind that include works relative to your file-system's root, not your Web site's document root -- so is the filename you're using an absolute path in your file-system?

And, whilst we're at it, have you got display_errors=On and error_reporting=E_ALL so that you see all error reports, including warnings.  Odds on this will give you some sort of clue.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 



To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux