Gets file type

# SplFileInfo::getType

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

SplFileInfo::getType — Gets file type

### 说明

public function SplFileInfo::getType(): string|false

Returns the type of the file referenced.

### 参数

此函数没有参数。

### 返回值

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.

### 错误／异常

Throws a RuntimeException on error.

### 示例

示例 #1 SplFileInfo::getType() example

    <?php

    $info = new SplFileInfo(__FILE__);
    echo $info->getType().PHP_EOL;

    $info = new SplFileInfo(dirname(__FILE__));
    echo $info->getType();

    ?>

以上示例的输出类似于：

    file
    dir

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open