Re: Re: How can I tell if a path is absolute?
| From: | Curt Zirzow | Date: | Sat, 17 Jul 2004 16:48:29 +0000 |
| Subject: | Re: Re: How can I tell if a path is absolute? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190851@lists.php.net to get a copy of this message | ||
* Thus wrote Trejkaz Xaoza:
> Jason Barnett wrote:
> > Ahhhh, methinks I have a competitor for a FileSystem Manager :) Perhaps I
> > misunderstand your problem, but this works fine for me (WinXP) because
> > realpath
> > [quote]Returns canonicalized absolute pathname[/quote]:
> >
> > <?php
> >
> > // we know __FILE__ is an absolute path
> > $file = __FILE__;
> > echo realpath(__FILE__) == $file ? 'The same path' : 'Not the same
> > path';
> >
> > ?>
> >
> > http://www.php.net/realpath
>
> That works because the value in __FILE__ seems to be both canonicalised and
> absolute.
>
> For an example which breaks, realpath('/home') on my server returns
> '/usr/home', so your example would claim that /home is not absolute. Yet,
> it is. :-/
A simple workaround is testing OS:
if (windows)
// use realpath method
} else {
$absolute = $path{0} == '/';
}
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!