Title: path_is_absolute
Published: April 25, 2014
Last modified: February 24, 2026

---

# path_is_absolute( string $path ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#wp--skip-link--target)

Tests if a given filesystem path is absolute.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#description)󠁿

For example, ‘/foo/bar’, or ‘c:\windows’.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#parameters)󠁿

 `$path`stringrequired

File path.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#return)󠁿

 bool True if path is absolute, false is not absolute.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#source)󠁿

    ```php
    function path_is_absolute( $path ) {
    	/*
    	 * Check to see if the path is a stream and check to see if its an actual
    	 * path or file as realpath() does not support stream wrappers.
    	 */
    	if ( wp_is_stream( $path ) && ( is_dir( $path ) || is_file( $path ) ) ) {
    		return true;
    	}

    	/*
    	 * 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] );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L2120)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L2120-L2148)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_is_stream()](https://developer.wordpress.org/reference/functions/wp_is_stream/)`wp-includes/functions.php` |

Tests if a given path is a stream URL

  |

| Used by | Description | 
| [path_join()](https://developer.wordpress.org/reference/functions/path_join/)`wp-includes/functions.php` |

Joins two filesystem paths together.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 2 content](https://developer.wordpress.org/reference/functions/path_is_absolute/?output_format=md#comment-content-4973)
 2.    [nlpro](https://profiles.wordpress.org/nlpro/)  [  5 years ago  ](https://developer.wordpress.org/reference/functions/path_is_absolute/#comment-4973)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fpath_is_absolute%2F%23comment-4973)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fpath_is_absolute%2F%23comment-4973)
 4.  This note was added while current WordPress version is 5.7
 5.  Please be aware that [path_is_absolute()](https://developer.wordpress.org/reference/functions/path_is_absolute/)
     returns **false** on a **Windows** platform when used on a normalized (abs) path(
     trac [#48289](https://core.trac.wordpress.org/ticket/48289)).
 6.      ```php
         var_dump( path_is_absolute( __FILE__ ) );
         var_dump( path_is_absolute( wp_normalize_path( __FILE__ ) ) );
         ```
     
 7.  *nix Result:
 8.  bool(true)
      bool(true)
 9.  Windows Result:
 10. bool(true)
      **bool(false)**
 11.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fpath_is_absolute%2F%3Freplytocom%3D4973%23feedback-editor-4973)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fpath_is_absolute%2F)
before being able to contribute a note or feedback.