Re: How can I tell if a path is absolute?
| From: | Tularis | Date: | Sat, 17 Jul 2004 10:37:31 +0000 |
| Subject: | Re: How can I tell if a path is absolute? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190833@lists.php.net to get a copy of this message | ||
Trejkaz Xaoza wrote:
Michael Ochs wrote: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/I'm not sure if you noticed, but I said I wanted it to be portable. Sure, "([A-Za-z]:)?[/\\]" would work to some extent, but would it work perfectly? As far as I can tell, the path "C:/" is _relative_ on Linux and BSD. Am I wrong? TX c:/ wouldn't even work as a path on unix systems. I don't know how paths look on MacOS systems, so can't help you with that. However, after removing the [a-z]: part of the path, you're stuck with an abosulute path that is of the same type as in Unix. In Unix systems absolute paths start with a forward-slash (eg. /usr/local or /home/me/, etc). After removing the c: from eg. c:/this/and/that, you're left with /this/and/that which looks pretty much the same :)