Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




path_is_absolute [ WordPress Function ]

path_is_absolute ( $path )
Parameters:
  • (string) $path File path
Returns:
  • (bool) True if path is absolute, false is not absolute.
Defined at:



Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows').

Source


<?php
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) == || $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] == '\\' );
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics