|
Posted by Daz on 01/11/07 02:40
Toby Inkster wrote:
> Daz wrote:
>
> > I am a little stumped at why when I try to include a file in same
> > directory as the script being processed, it looks in the same directory
> > as the script that included it to begin with. Is there any way I can
> > get around this?
>
> include dirname(__FILE__).'/myfile.php';
>
> However, it's a good idea to have a specific "includes" directory, put all
> your included files into there and then just refer to them as:
>
> include 'myfile.php';
>
> without including a directory path at all(!) but instead using the
> include_path setting to specify where include files will be found.
>
> http://www.php.net/manual/en/ini.core.php#ini.include-path
>
> --
> Toby A Inkster BSc (Hons) ARCS
Hi Toby.
Thanks for that, I think that's the solution I am looking for. The way
my website is designed, is so that everything goes through the main
index.php file, and any core files (user functions, database functions,
cookie functions etc...), are all included by the main index.php file,
which validates the user, and then loads the correct module according
to the search parameter in the URL. I know that there aren't many
websites that do this, but after much careful thought I decided that it
would make more sense as I won't have to write so many repeated lines
of code, thus taking up less space on the server, and hopefully saving
mistakes like missing code/core functions.
Many thanks again, and all the best. :)
Daz.
[Back to original message]
|