Re: Re: Handling Linux directory paths in Win32
| From: | Jason Barnett | Date: | Thu, 22 Jul 2004 09:24:41 +0000 |
| Subject: | Re: Re: Handling Linux directory paths in Win32 | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-24240@lists.php.net to get a copy of this message | ||
I actually use Apache so I knew it was safe for that, but didn't realize it would work for IIS as well (you just never know with Microsoft ;) ). Good to know, thanks!
Paul Menard wrote:
Just a comment or thought on Jason's reply. I thought you could use '/' as the seperator and the PHP engine would figure out based on the run-time OS what the actual path format would be. Hence you can use actual path names like; E:/path1/path2/path3/somefile.php in your include and require statements. At least my code uses the '/' on these types of paths and works fine on Windows and *nix systems. IIS and Apache both. FPM --- Jason Barnett <jasbarne@indiana.edu> wrote:I've run into this exact problem many times. Two things: 1) use the PEAR constant DIRECTORY_SEPERATOR, or define it yourself if (PHP_OS == 'Win32' || PHP_OS == 'WinNT') { define('DIRECTORY_SEPERATOR', '\'); } else { define('DIRECTORY_SEPERATOR', '/'); } 2) I have two ways that I solve the relative include problem. a) include_once dirname(__FILE__) . 'path/to/relative/include.php'; or for class libraries b) function __autoload($class) {// Use your own logic, I have mine defined to do PEAR-like loading $file = str_replace('_', DIRECTORY_SEPERATOR, $class); include_once($file . '.php'); }As that would mean the macro code would not slow the linux machine down at all when running the php script if it did not even have to evaluate to see if it did need to run the macro function, although I know php is a scripted language and not compiled like C/C++ so I don't think its possibleNote: PHP goes through the compile step, it's just that everything is compiled on demand. -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php