FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Seeking help with relative and absolute paths
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Seeking help with relative and absolute paths [message #180818 is a reply to message #180817] Wed, 20 March 2013 05:45 Go to previous messageGo to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma:
Senior Member
On 20/03/13 05:45, The Frog wrote:

> I have a directory under the site root called config, and another called scripts. In the config directory I have some basic stuff like constants that I define for the site (eg/ db.php for the database constants such as username, server, etc...). Referencing this with the following php from index.php works fine:
> <?PHP require_once 'config/db.php';
> require_once 'config/config.php';
> //do stuff here
> ?>
>
> Where I am having a problem is when I try to reference the files from a script that is in the scripts directory (or any other for that matter). I have tried to set a constant in the config/config.php file that points to the root of the site with the following:
> define(APP_ROOT, realpath( dirname( __FILE__ ) ).'/');

You have the super global $_SERVER['DOCUMENT_ROOT'], so you can use

require_once $_SERVER['DOCUMENT_ROOT'].'/config/db.php';

ypu can also us the include_path in php.ini and add the path to the
document root in which case you then can use:

require_once 'config/db.php';


--

//Aho
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Fatal error!
Next Topic: Hot list for BA, QA – Analyst, Java Developer, Business Analyst/ Project Coordinator & SAP Business Object Developer
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Feb 17 00:27:46 GMT 2025

Total time taken to generate the page: 0.05507 seconds