timostamm/pathinfo

一个用于操作文件系统路径的具有流畅界面的对象

v1.1.0 2023-05-08 10:39 UTC

This package is auto-updated.

Last update: 2024-09-08 16:09:22 UTC


README

build Packagist PHP Version GitHub tag License

一个用于操作文件系统路径的具有流畅界面的对象。

示例

$root = Path::info('/var/wwwroot/index.html');

$root->equals('/foo/../var/root/index.html'); // -> true
$root->isIn('/var/wwwroot/'); // -> true
$root->isAbsolute(); // -> true

$root->dirname(); // -> "/var/wwwroot/"
$root->filename(); // -> "index.html"
$root->basename(); // -> "index"
$root->extension(); // -> "html"

Path::info('../log.txt')
	->abs($root)
	->get(); // -> "/var/log.txt"

Path::info('/foo/../var/root/index.html')
	->normalize()
	->get(); // -> "/var/wwwroot/index.html"