Re: Handling Linux directory paths in Win32

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux