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
<?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
2016-02-24 16:20:15
Comments
Leave a Comment

Please login to continue.