SplFileInfo::getType
PHP function
Edit on GitHub ✎
(PHP 5 >= 5.1.2, PHP 7, PHP 8)
Gets file type
Description
SplFileInfo::getType(): string|false
Returns the type of the file referenced.
Parameters Parameters
Return Values
A string representing the type of the entry. May be one of file, link, dir, block, fifo, char, socket, or unknown, or false on failure.
Errors/Exceptions
Throws a RuntimeException on error.
Examples
SplFileInfo::getType() example
php
<?php
$info = new SplFileInfo(__FILE__);
echo $info->getType().PHP_EOL;
$info = new SplFileInfo(dirname(__FILE__));
echo $info->getType();
?>The above example will output something similar to:
output
file
dir