How can I tell if a path is absolute?
| From: | Trejkaz Xaoza | Date: | Sat, 17 Jul 2004 08:24:42 +0000 |
| Subject: | How can I tell if a path is absolute? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-190828@lists.php.net to get a copy of this message | ||
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