Re: How can I tell if a path is absolute?
| From: | Michael Ochs | Date: | Sat, 17 Jul 2004 08:54:09 +0000 |
| Subject: | Re: How can I tell if a path is absolute? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190830@lists.php.net to get a copy of this message | ||
Hi,
maybe you could try it with regular expressions! "[A-Z]:\\" or better
"[C-Z]:\\" because A and B is used just for floppy drives...
Take a look at www.php.net/preg_match/
Bye, Michael
"Trejkaz Xaoza" <trejkaz@xaoza.net> schrieb im Newsbeitrag
news:20040717082435.76018.qmail@pb1.pair.com...
> Hi!
>
> I used to detect whether a path is absolute by seeing if the first
character
> is a forward slash.
>
> Unfortunately, Windows absolute paths are in a different syntax like
"C:\",
> and I don't know what other random systems might have for their syntax in
> the future.
>
> So, is there a portable way to tell if a path is absolute or not? I
thought
> about comparing the start of the path with realpath('/'), but this only
> works if the path starts with "C:" and fails for "D:" and other drives.
>
> 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