downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

flock> <filesize
Last updated: Fri, 03 Sep 2010

view this page in

filetype

(PHP 4, PHP 5)

filetypeファイルタイプを取得する

説明

string filetype ( string $filename )

指定したファイルのタイプを返します。

パラメータ

filename

ファイルへのパス。

返り値

ファイルのタイプを返します。返される値は fifo、char、dir、 block、link、file、socket および unknown のいずれかです。

エラーが発生すると FALSE を返します。 また filetype() は stat コールに失敗したり、 未知のファイルタイプであったりした場合に E_NOTICE メッセージを発行します。

例1 filetype() の例

<?php

echo filetype('/etc/passwd');  // ファイル
echo filetype('/etc/');        // ディレクトリ

?>

注意

注意: この関数の結果は キャッシュされます。詳細は、clearstatcache() を参照してください。

ヒント

PHP 5.0.0 以降、この関数は、 何らかの URL ラッパーと組合せて使用することができます。 どのラッパーが stat() ファミリーをサポートしているか のリストについては、サポートするプロトコル/ラッパー を参照してください。

参考

  • is_dir() - ファイルがディレクトリかどうかを調べる
  • is_file() - 通常ファイルかどうかを調べる
  • is_link() - ファイルがシンボリックリンクかどうかを調べる
  • file_exists() - ファイルまたはディレクトリが存在するかどうか調べる
  • stat() - ファイルに関する情報を取得する
  • mime_content_type() - ファイルの MIME Content-type を検出する (非推奨)



add a note add a note User Contributed Notes
filetype
7r6ivyeo at mail dot com
22-Nov-2008 01:29
I use the CLI version of PHP on Windows Vista.  Here's how to determine if a file is marked "hidden" by NTFS:

<?php
function is_hidden_file($fn) {

   
$attr = trim(exec('FOR %A IN ("'.$fn.'") DO @ECHO %~aA'));

    if(
$attr[3] === 'h')
        return
true;

    return
false;
}
?>

Changing <?php if($attr[3] === 'h') ?> to <?php if($attr[4] === 's') ?> will check for system files.

This should work on any Windows OS that provides DOS shell commands.
ruach at chpc dot utah dot edu
11-Mar-2004 01:11
There are 7 values that can be returned. Here is a list of them and what each one means

block: block special device

char: character special device

dir: directory

fifo: FIFO (named pipe)

file: regular file

link: symbolic link

unknown: unknown file type

flock> <filesize
Last updated: Fri, 03 Sep 2010
 
 
show source | credits | sitemap | contact | advertising | mirror sites