Re: How can I tell if a path is absolute?
| From: | Trejkaz Xaoza | Date: | Sat, 17 Jul 2004 12:26:52 +0000 |
| Subject: | Re: How can I tell if a path is absolute? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190841@lists.php.net to get a copy of this message | ||
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. :-/
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 <trejkaz@xaoza.net>
Web site: http://xaoza.net/trejkaz/
Jabber ID: trejkaz@jabber.xaoza.net
GPG Fingerprint: 9EEB 97D7 8F7B 7977 F39F A62C B8C7 BC8B 037E EA73