RE: [PHP] help with fopen path
| From: | Graham Cossey | Date: | Tue, 09 Nov 2004 21:40:08 +0000 |
| Subject: | RE: [PHP] help with fopen path | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201639@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Giles Roadnight [mailto:giles@roadnight.name]
> Sent: 09 November 2004 13:07
> To: php-general@lists.php.net
> Subject: [PHP] help with fopen path
>
>
> Hi All
>
> I'm developing a fusebox PHP app and have a class in a /classes
> directory that opens an xml file in a directory below the site root
> using this path: "../siteconfig.xml"
>
> All of the places I have used this class from so far have been in the
> site root. I am now starting some pages in a sub directory. When I use
> this class it says it can't open the file. I have tried
> "../../siteconfig.xml" instead but it doesn't work either.
>
> What's the best way to go about fixing this? I'm quite new to php and
> I'm not sure where the relative path is taken from - i.e. is it the
> index.php page or the class (obviously not) or my switch file or what?
>
Just a thought:
If your referencing a file within a PHP script that is included/required
within another script the path should be relative to the 'parent' script.
I am guessing that if you make reference above the site root (using ../../)
the site root will be assumed.
If you have access to the web server config try setting up an alias
such as /config which points to the directory containing your config xml
so that your scripts can reference "/config/siteconfig.xml" from any
directory.
HTH
Graham