Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #8754
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "J.O. Aho" <user@example.net> |
| Newsgroups | comp.lang.php |
| Subject | Re: Seeking help with relative and absolute paths |
| Date | Wed, 20 Mar 2013 06:45:23 +0100 |
| Lines | 24 |
| Message-ID | <aqt0njFd0r2U1@mid.individual.net> (permalink) |
| References | <d6258610-56e6-423d-82f7-5ab3b3f88eee@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net bPvkKRF32bYIHz2ga/CQSA/qYHnWmx429MpkNZJ1Q2Y84W60y8 |
| Cancel-Lock | sha1:CYPwCrJKjmHfQQKbnYes1GupvNE= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130222 Thunderbird/17.0.3 |
| In-Reply-To | <d6258610-56e6-423d-82f7-5ab3b3f88eee@googlegroups.com> |
| Xref | csiph.com comp.lang.php:8754 |
Show key headers only | View raw
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
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Seeking help with relative and absolute paths The Frog <mr.frog.to.you@googlemail.com> - 2013-03-19 21:45 -0700
Re: Seeking help with relative and absolute paths "J.O. Aho" <user@example.net> - 2013-03-20 06:45 +0100
Re: Seeking help with relative and absolute paths Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-20 06:46 -0400
Re: Seeking help with relative and absolute paths "J.O. Aho" <user@example.net> - 2013-03-20 19:10 +0100
Re: Seeking help with relative and absolute paths The Frog <mr.frog.to.you@googlemail.com> - 2013-03-21 21:24 -0700
Re: Seeking help with relative and absolute paths "J.O. Aho" <user@example.net> - 2013-03-22 08:11 +0100
Re: Seeking help with relative and absolute paths The Frog <Mr.frog.to.you@googlemail.com> - 2013-03-22 19:38 +1100
Re: Seeking help with relative and absolute paths Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-22 09:01 -0400
Re: Seeking help with relative and absolute paths "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-03-22 14:33 +0100
Re: Seeking help with relative and absolute paths Scott Johnson <noonehome@chalupasworld.com> - 2013-03-22 06:12 -0700
Re: Seeking help with relative and absolute paths The Frog <Mr.frog.to.you@googlemail.com> - 2013-03-23 23:57 +1100
Re: Seeking help with relative and absolute paths Scott Johnson <noonehome@chalupasworld.com> - 2013-03-23 07:25 -0700
Re: Seeking help with relative and absolute paths "J.O. Aho" <user@example.net> - 2013-03-23 16:24 +0100
Re: Seeking help with relative and absolute paths The Frog <Mr.frog.to.you@googlemail.com> - 2013-03-24 15:09 +1100
Re: Seeking help with relative and absolute paths Scott Johnson <noonehome@chalupasworld.com> - 2013-03-24 07:27 -0700
Re: Seeking help with relative and absolute paths Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-24 12:24 -0400
csiph-web