SplFileInfo::getType

(PHP 5 >= 5.1.2, PHP 7)
Gets file type
public string SplFileInfo::getType ( void )

Returns the type of the file referenced.

Returns:

A string representing the type of the entry. May be one of file, link, or dir

Exception:

Throws a RuntimeException on error.

Examples:
SplFileInfo::getType() example
1
2
3
4
5
6
7
8
9
<?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:

file
dir
doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.