Re: Re: Handling Linux directory paths in Win32

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

 



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@xxxxxxxxxxx> 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 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
> 
> 

-- 
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