Re: Environment variable solution to relative includes (will work for HTML too.)

From: Date: Thu, 12 Jul 2001 15:07:55 +0000
Subject: Re: Environment variable solution to relative includes (will work for HTML too.)
Groups: php.dev 
Request: Send a blank email to php-dev+get-59839@lists.php.net to get a copy of this message
>> There are better ways of doing this... <snip> What I always do, is using absolute paths ('/images/image3.png'), and in some init I define some constants that contain IMG_DIR, etc, so you can change it in one place. I wish I could do this but I'm designing a web site creation / management system with the ability to pull in files from anywhere as part of its templating engine. Your solution would work if it a site but I need the system to be as flexible as possible. I believe that the solution I proposed earlier: i.e., having an environment variable (eg. $PHP_CURRENT_INCLUDE or something) contain the path to the latest included file. That way the included page could decide how it wants to include other files *and* the variable could be used to link to elements (eg. images, etc.) in the same directory as the included file. Perhaps there could even be two variables (along the lines of $PHP_CURRENT_INCLUDE_PATH and $PHP_CURRENT_INCLUDE_URL), one the path to the include file and the other an absolute URL (e.g. the file could be included from another server). These two should cover anything that anyone might possibly want to do in an included file and offer complete flexibility without having to rewrite any functions. Should I submit this as a feature request? All my best, Aral :) ______________________________ (aral@kismia.com) New Media Producer, Kismia, Inc. (aral@american.edu) Adj. Prof., American University ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ______________________________ (aral@kismia.com) New Media Producer, Kismia, Inc. (aral@american.edu) Adj. Prof., American University ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

« previous php.dev (#59839) next »