Supported Versions: PHP 4 >= 4.0.3, PHP 5, PHP 7, PHP 8
Returns information about a file path
<?php pathinfo(string $path, int $flags = PATHINFO_ALL): array|string
<?php public function name($path)
{
return pathinfo($path, PATHINFO_FILENAME);
}
<?php public function basename($path)
{
return pathinfo($path, PATHINFO_BASENAME);
}
<?php public function dirname($path)
{
return pathinfo($path, PATHINFO_DIRNAME);
}
<?php public function extension($path)
{
return pathinfo($path, PATHINFO_EXTENSION);
}
<?php ViewFacade::addLocation(sys_get_temp_dir());
}
$tempFileInfo = pathinfo(tempnam($tempDirectory, 'laravel-blade'));
$tempFile = $tempFileInfo['dirname'].'/'.$tempFileInfo['filename'].'.blade.php';
<?php public function image($name, $width = 10, $height = 10)
{
return new File($name, $this->generateImage(
$width, $height, pathinfo($name, PATHINFO_EXTENSION)
));
}
<?php public static function from($filename)
{
$extension = pathinfo($filename, PATHINFO_EXTENSION);
return self::get($extension);
}
<?php protected function fileIsServable(string $publicPath, string $pathToFile): bool
{
return $pathToFile &&
! in_array(pathinfo($pathToFile, PATHINFO_EXTENSION), ['php', 'htaccess', 'config']) &&
str_starts_with($pathToFile, $publicPath) &&
is_file($pathToFile);
}
<?php $publicPath = $context->publicPath;
$swooleResponse->status(200);
$swooleResponse->header('Content-Type', MimeType::get(pathinfo($request->path(), PATHINFO_EXTENSION)));
$swooleResponse->sendfile(realpath($publicPath.'/'.$request->path()));
}
<?php public function setFileInfoFromPath($path)
{
$info = pathinfo($path);
$this->dirname = array_key_exists('dirname', $info) ? $info['dirname'] : null;
$this->basename = array_key_exists('basename', $info) ? $info['basename'] : null;
$this->extension = array_key_exists('extension', $info) ? $info['extension'] : null;
<?php }
if ($format === null) {
$format = pathinfo($path, PATHINFO_EXTENSION);
}
$data = $this->encode($format, $quality);
<?php public function filename()
{
return pathinfo($this->path())['filename'];
}
<?php public function basename()
{
return pathinfo($this->path())['basename'];
}
<?php public function folder()
{
$dirname = pathinfo($this->path())['dirname'];
return $dirname === '.' ? '/' : $dirname;
}
<?php $filename = $filename ?: $this->filename();
$oldPath = $this->path();
$oldMetaPath = $this->metaPath();
$newPath = Str::removeLeft(Path::tidy($folder.'/'.$filename.'.'.pathinfo($oldPath, PATHINFO_EXTENSION)), '/');
if ($oldPath === $newPath) {
return $this;