"Sean Malloy" <[EMAIL PROTECTED]> wrote... : > Moving to PHP from an ASP backgroun, I always found one thing really > annoying about PHP. > > With ASP, you could have a file structure such as: > > SYSTEM > |--HTML > | |--header.asp > | > |--LOGIC > | |--engine.asp > | > |--core.asp > > in default.asp, you would > <!--#include file="system/core.asp"--> > in core.asp, engine.asp would be included as such > <!--#include file="LOGIC/engine.asp"--> > in engine.asp, header.asp would be included as such > <!--#include file="../HTML/header.asp"--> > > > Its a bad example. However, it demonstrates that the relative path for each > include changed depending on what file was being included. > > PHP doesn't do that. Which is kind of annoying, but you get used to it.. But > I've come up with a work around.
Wrong. PHP doesn't care that much about these paths themselves, both ASP and PHP need the path to give it to the filesystem and to retrieve the file pointer. Which means, on the same system both PHP and ASP would behave the same way to get the same files from the same locations. Difference stays in the fact that you can also configure it in the php.ini file. For instance, if you add '.' in php.ini then every file request will be relative to your current location (check it, it might not be set for you - include_path directive). > htdocs/index.php > include('./system/core.php'); dot `.' is the current directory *relative* to the current directory - makes not much sense in many cases. > htdocs/system/core.php > define('CORE_PATH', str_replace('core.php', '', __FILE__)); a cute way to accomplish the above is: define('CORE_PATH', dirname(__FILE__) . '/'); > include(CORE_PATH.'logic/engine.php'); > > htdocs/system/logic/engine.php > include(CORE_PATH.'html/header.php'); > > and so on and so forth. searching for __FILE__, and removing the filename > from the output, gives you a sort of relative path hack. > > Hope someone finds that useful -- Maxim Maletsky [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php