Re: Handling Linux directory paths in Win32

From: Date: Wed, 21 Jul 2004 10:13:18 +0000
Subject: Re: Handling Linux directory paths in Win32
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-24232@lists.php.net to get a copy of this message
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 possible
Note: PHP goes through the compile step, it's just that everything is compiled on demand.

« previous php.windows (#24232) next »