Definition:
function path_is_absolute( $path ) {}
Test if a give filesystem path is absolute (‘/foo/bar’, ‘c:\windows’).
Parameters
- string $path: File path
Return values
returns:True if path is absolute, false is not absolute.
Source code
function path_is_absolute( $path ) {
// this is definitive if true but fails if $path does not exist or contains a symbolic link
if ( realpath($path) == $path )
return true;
if ( strlen($path) == 0 || $path[0] == '.' )
return false;
// windows allows absolute paths like this
if ( preg_match('#^[a-zA-Z]:\\\\#', $path) )
return true;
// a path starting with / or \ is absolute; anything else is relative
return ( $path[0] == '/' || $path[0] == '\\' );
}
2485

February 12, 2011 


No comments yet... Be the first to leave a reply!