WP_CLI
Extractor::path_is_relative()
Check whether a path is relative-
Method of the class: Extractor{}
No Hooks.
Return
true|false
. Whether the path is relative.
Usage
$result = Extractor::path_is_relative( $path );
- $path(string) (required)
- Path to check.
Extractor::path_is_relative() Extractor::path is relative code WP-CLI 2.8.0-alpha
private static function path_is_relative( $path ) { if ( '' === $path ) { return true; } // Strip scheme. $scheme_position = strpos( $path, '://' ); if ( false !== $scheme_position ) { $path = substr( $path, $scheme_position + 3 ); } // UNIX root "/" or "\" (Windows style). if ( '/' === $path[0] || '\\' === $path[0] ) { return false; } // Windows root. if ( strlen( $path ) > 1 && ctype_alpha( $path[0] ) && ':' === $path[1] ) { // Special case: only drive letter, like "C:". if ( 2 === strlen( $path ) ) { return false; } // Regular Windows path starting with drive letter, like "C:/ or "C:\". if ( '/' === $path[2] || '\\' === $path[2] ) { return false; } } return true; }