Oihana PHP

isLocalPath.php

Table of Contents

Functions

isLocalPath()  : bool
Determines whether the given path refers to a local file system location.

Functions

isLocalPath()

Determines whether the given path refers to a local file system location.

isLocalPath(string $path) : bool

A path is considered "local" if:

  • It is not empty.
  • It does not contain a URL-like scheme (e.g. http://, ftp://, s3://, etc.).

This function uses a lightweight string check to detect the presence of ://, which is common in remote paths or stream wrappers.

Parameters
$path : string

The path to check. Can be relative, absolute, or URL-style.

Tags
example
isLocalPath('/var/log/app.log');     // true
isLocalPath('C:\\Users\\Admin');     // true
isLocalPath('https://example.com');  // false
isLocalPath('s3://my-bucket/file');  // false
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
bool

True if the path is local; false if it looks like a remote or virtual path.


        
On this page

Search results