Re: [PHP] include() and paths
Patrick Teague wrote: > ok, so this makes alot of since... if I move my website from one server to > another server I'll have to go through every single file & redo the > directory structure? Isn't this the reason for the includes... so you > don't have to go through every single file to make changes? Maybe I should > go back to ASP... > > #include virtual="/includes/myinclude.inc" > > or is there a way to get this to work via php on apache? Per http://www.php.net/manual/en/function.ini-set.php, PHP_INCLUDE_PATH is an 'ini' setting which you can change - you could either set it in your php.ini once, and point it to one common 'includes' direcotry. Or possibly set it per apache virtual server (via .htaccess perhaps in a main root directory). Another thought is to simply make all your include statements use a constant, such as DOCUMENT_ROOT or something else (we use something else but the idea is the same). Yes, all includes need to be written as include(MYDIRPATH."/relative/stuff.php"); Also, try ini_set(PHP_INCLUDE_PATH,DOCUMENT_ROOT); at the top of your page(s). That might do the trick. but it makes everything a heck of a lot more portable. Don't go back to ASP. If you really want to use stuff Apache supports that via .shtml files. There are probably ways of getting the two to work together (PHP and SSI) though I'm not sure why you'd want to do so. :) Remember ASP is a framework, and VBScript is the popular language there. VBScript doesn't support includes at all - it's ASP calling an SSI interpreter, include()ing things, then passing to the language. PHP is just a language. There are some pretty ugly, inelegant things going on under the hood with respect to includes under ASP - if you want gorey details let me know. :) After writing all this I see it's basically a rehash of the 9/2/2001 posting in the user comments under include at the php manual site. Is there a reason one of those 3 options isn't viable? Michael Kimsal http://www.phphelpdesk.com Taking the ? out of http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and paths
ok, so this makes alot of since... if I move my website from one server to another server I'll have to go through every single file & redo the directory structure? Isn't this the reason for the includes... so you don't have to go through every single file to make changes? Maybe I should go back to ASP... #include virtual="/includes/myinclude.inc" or is there a way to get this to work via php on apache? Patrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] include() and paths
> -Original Message- > From: Nick Wilson [mailto:[EMAIL PROTECTED]] > Sent: 01 March 2002 17:30 > To: PHP-General > Subject: Re: [PHP] include() and paths > > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > * and then Nick Winfield declared > > I didn't catch the first part of this thread (rampant > deletion ahoy) so > > please excuse if I am talking nadgers. The way I see it, if you are > > calling includes/requires from within other includes, the > path is that of > > the script that makes the first include. If that makes any sense. > > Sure does, just wondered if anyone could see a way round my > little wish > :-) AFAIK there is no easy way to do this and as neither the > manual nor > this list has been able to tell me different I'll have to find another > solution. Thanks for the help though! H'mm, the only even *vaguely* useful thing I can think of here is that dirname(__FILE__) should give you the full directory path of the *current* include file. Fine for "here-relative" names, but you'd need to manipulate it further to do the equivalent of ..-type relativities. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and paths
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * and then DL Neil declared > > > RTFM the four pages from > > > http://www.php.net/manual/en/function.require.php.; There's quite a > bit > > > of advice/experience in the user annotations! > > > > Please don't RTFM me, that's the first place I went. I didn't find > what > > I'm looking for so I came here. > > It's a two-way street: please tell us what you have done so that we > don't waste our time trying to help you with 'basic' suggestions when > you're looking for 'the next step up'. Particularly if your enquiry is > basically the hope that the (good quality/fine) manual doesn't mention > something - a most unlikely scenario. If you just want to rude and superior please do it elsewhere, this is a busy list. - -- - --- www.explodingnet.com |Projects, Forums and +Articles for website owners - -- Nick Wilson -- |and designers. -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) iD8DBQE8f7r8HpvrrTa6L5oRAttAAKCWKkby/MBC5rVbJjUAhGahyOJkawCffA2o c3G6zp9KuN2ie8A/y9rEpl4= =cyUe -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and paths
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * and then Nick Winfield declared > I didn't catch the first part of this thread (rampant deletion ahoy) so > please excuse if I am talking nadgers. The way I see it, if you are > calling includes/requires from within other includes, the path is that of > the script that makes the first include. If that makes any sense. Sure does, just wondered if anyone could see a way round my little wish :-) AFAIK there is no easy way to do this and as neither the manual nor this list has been able to tell me different I'll have to find another solution. Thanks for the help though! - -- - --- www.explodingnet.com |Projects, Forums and +Articles for website owners - -- Nick Wilson -- |and designers. -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) iD8DBQE8f7q1HpvrrTa6L5oRArMgAJ9ETCkt5vxJSVs7O9Ervfkl9wxc4gCdFG9q Hp8nJGb56lec5ckoIbdb7WI= =4FXP -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and paths
and Nick Wilson opined in what could be seen to be an arrogant fashion... > * and then DL Neil declared > > > masterfile.inc lives in /var/www/includes/ and contains this line: > > > include("/var/www/includes/anotherfile.inc"); > > > > > > in index.php I include masterfile.inc and thus get anotherfile.inc. > > > > > > What I'd like to know though is, is it possible to have the include > > line > > > in masterfile.inc specify a url *relative* to itself? > > > like: > > > // masterfile.inc > > > include("anotherfile.inc"); // now the path is relative. > > > > > > AFAIK the options are absolute addressing, relative addressing (to the > > php.ini), and http access. > > > > RTFM the four pages from > > http://www.php.net/manual/en/function.require.php. There's quite a bit > > of advice/experience in the user annotations! > > Please don't RTFM me, that's the first place I went. I didn't find what > I'm looking for so I came here. It's a two-way street: please tell us what you have done so that we don't waste our time trying to help you with 'basic' suggestions when you're looking for 'the next step up'. Particularly if your enquiry is basically the hope that the (good quality/fine) manual doesn't mention something - a most unlikely scenario. =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and paths
On Fri, 1 Mar 2002, Nick Wilson wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > * and then DL Neil declared > > > masterfile.inc lives in /var/www/includes/ and contains this line: > > > include("/var/www/includes/anotherfile.inc"); > > > > > > in index.php I include masterfile.inc and thus get anotherfile.inc. > > > > > > What I'd like to know though is, is it possible to have the include > > line > > > in masterfile.inc specify a url *relative* to itself? > > > like: > > > // masterfile.inc > > > include("anotherfile.inc"); // now the path is relative. > > > > > > AFAIK the options are absolute addressing, relative addressing (to the > > php.ini), and http access. > > > > RTFM the four pages from > > http://www.php.net/manual/en/function.require.php.; There's quite a bit > > of advice/experience in the user annotations! > > Please don't RTFM me, that's the first place I went. I didn't find what > I'm looking for so I came here. I didn't catch the first part of this thread (rampant deletion ahoy) so please excuse if I am talking nadgers. The way I see it, if you are calling includes/requires from within other includes, the path is that of the script that makes the first include. If that makes any sense. So if you have a file called includes.php in your /home/webroot that includes/requires files in a subdir called /home/webroot/stuff/ and those files include/require other files within that same directory (such as /home/webroot/stuff/class.cheese.php), then the includes would look like this: # index.php include("includes.php"); . . . . # includes.php include("stuff/dbstuff.php"); . . . . # stuff/dbstuff.php include ("stuff/class.cheese.php"); . . . . Am I making any sense? :-) Regards, Nick Winfield. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and paths
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * and then DL Neil declared > > masterfile.inc lives in /var/www/includes/ and contains this line: > > include("/var/www/includes/anotherfile.inc"); > > > > in index.php I include masterfile.inc and thus get anotherfile.inc. > > > > What I'd like to know though is, is it possible to have the include > line > > in masterfile.inc specify a url *relative* to itself? > > like: > > // masterfile.inc > > include("anotherfile.inc"); // now the path is relative. > > > AFAIK the options are absolute addressing, relative addressing (to the > php.ini), and http access. > > RTFM the four pages from > http://www.php.net/manual/en/function.require.php.; There's quite a bit > of advice/experience in the user annotations! Please don't RTFM me, that's the first place I went. I didn't find what I'm looking for so I came here. - -- - --- www.explodingnet.com |Projects, Forums and +Articles for website owners - -- Nick Wilson -- |and designers. -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) iD8DBQE8f2/pHpvrrTa6L5oRAgH+AJ0bbArcqX1Um1muNIjV789qCEvv/gCfW9RA jFT4TxiP5n4tUpgPl5NAG1I= =/ZY3 -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include() and paths
Hi Nick, > masterfile.inc lives in /var/www/includes/ and contains this line: > include("/var/www/includes/anotherfile.inc"); > > in index.php I include masterfile.inc and thus get anotherfile.inc. > > What I'd like to know though is, is it possible to have the include line > in masterfile.inc specify a url *relative* to itself? > like: > // masterfile.inc > include("anotherfile.inc"); // now the path is relative. AFAIK the options are absolute addressing, relative addressing (to the php.ini), and http access. RTFM the four pages from http://www.php.net/manual/en/function.require.php. There's quite a bit of advice/experience in the user annotations! Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] include() and paths
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi all, Here's the scenario. masterfile.inc lives in /var/www/includes/ and contains this line: include("/var/www/includes/anotherfile.inc"); in index.php I include masterfile.inc and thus get anotherfile.inc. Simple (I hope) What I'd like to know though is, is it possible to have the include line in masterfile.inc specify a url *relative* to itself? like: // masterfile.inc include("anotherfile.inc"); // now the path is relative. Many thanks - -- - --- www.explodingnet.com |Projects, Forums and +Articles for website owners - -- Nick Wilson -- |and designers. -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) iD8DBQE8f1VMHpvrrTa6L5oRAogTAJ46IwBbwFVLnVhNEG2qIj9ZqzXX1QCeMinj 6Y7FWqh5wFGqVEYe58LkZTM= =YtcD -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php