Curt Zirzow wrote:
> A simple workaround is testing OS:
> 
> if (windows)
>   // use realpath method
> } else {
>   $absolute = $path{0} == '/';
> }

I don't know what the "realpath" method is since every one I've been given
that involves realpath so far doesn't work.

But here's what I'm doing now:

    function is_absolute($path)
    {
        $regex = (PHP_OS == 'WINNT' || PHP_OS == 'WIN32')
            ? "/^([a-z][A-Z]:)?[\/\\]/"
            : "/^\//";

        return (boolean) preg_match($regex, $path);
    }

Does that look safe enough?  It works for Linux but since I have no Windows
environments to test on I have no idea if it works properly on Windows.

TX

-- 
'Every sufficiently advanced technology is indistinguishable from magic' -
Arthur C Clarke
'Every sufficiently advanced magic is indistinguishable from technology' -
Tom Graves

             Email: Trejkaz Xaoza <[EMAIL PROTECTED]>
          Web site: http://xaoza.net/trejkaz/
         Jabber ID: [EMAIL PROTECTED]
   GPG Fingerprint: 9EEB 97D7 8F7B 7977 F39F  A62C B8C7 BC8B 037E EA73

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

Reply via email to