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, 13 Nov 2009

view this page in

filetype

(PHP 4, PHP 5)

filetypeLê o tipo do arquivo

Descrição

string filetype ( string $filename )

Retorna o tipo do arquivo.

Parâmetros

filename

Caminho até o arquivo.

Valor Retornado

Retorna o tipo do arquivo. Os valores possíveis são fifo, char, dir, block, link, file, socket e unknown (desconhecido).

Retorna FALSE se ocorrer algum erro. filetype() também produzirá uma mensagem E_NOTICE se a chamada stat falhar ou se o tipo do arquivo for desconhecido.

Exemplos

Exemplo #1 Exemplo de filetype()

<?php

echo filetype('/etc/passwd');  // file
echo filetype('/etc/');        // dir

?>

Notas

Nota: O resultado desta função é cacheada. Veja clearstatcache() para mais detalhes.

Dica

A partir do PHP 5.0.0, esta função também pode ser utilizada com alguns wrappers URL. Veja List of Supported Protocols/Wrappers para uma lista de quais wrappers são suportados pela família de funções stat().

Veja Também

  • is_dir() - Diz se o caminho é um diretório
  • is_file() - Informa se o arquivo é um arquivo comum (não é diretório)
  • is_link() - Diz se o arquivo é um link simbólico (symbolic link)
  • file_exists() - Checa se um arquivo ou diretório existe
  • stat() - Obtem informações sobre um arquivo
  • mime_content_type() - Detecta o tipo MIME de um arquivo



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, 13 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites