略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: SplFileInfo::getType

2024-11-14

SplFileInfo::getType

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

SplFileInfo::getTypeGets file type

说明

public 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
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/splfileinfo.gettype.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3