Index: phpdoc/pt_BR/functions/filesystem.xml
diff -u phpdoc/pt_BR/functions/filesystem.xml:1.4 phpdoc/pt_BR/functions/filesystem.xml:1.5
--- phpdoc/pt_BR/functions/filesystem.xml:1.4 Thu Nov 15 05:35:35 2001
+++ phpdoc/pt_BR/functions/filesystem.xml Thu Nov 15 09:59:55 2001
@@ -1,2959 +1,2959 @@
-
-
-
- Funções do Filesystem
- Filesystem
-
-
-
- basename
-
- Retorna a parte do nome do arquivo do path
-
-
-
- Descrição
-
-
- string basename
- string path
- string suffixo
-
-
-
- Dado uma string contendo um path para um arquivo, essa função irá
- retornar o nome base do arquivo.
- Se o nome do arquivo é terminado em um suffixo
- este tambem será retirado.
-
-
- No Windows, tanto a barra (/) quanto a
- barrainvertida (\) são usadas como caracter de
- separacao do path. Em outros ambientes, somente a barra
- (/).
-
-
-
- exemplo do basename
-
-$path = "/home/httpd/html/index.php";
-$arquivo = basename ($path); // $arquivo conterá "index.php"
-$arquivo = basename ($path,".php"); // $arquivo conterá "index"
-
-
-
-
-
- O parametro suffixo foi adicionado no PHP 4.1.0.
-
-
-
- Veja também: dirname
-
-
-
-
-
-
- chgrp
- Modifica o grupo do arquivo
-
-
- Descrição
-
-
- int chgrp
- string arquivo
- mixed grupo
-
-
-
- Tenta modificar o grupo do
- arquivo para o
- grupo. Somente o superusuário pode mudar
- o grupo de um arquivo arbitrário; outros usuários podem somente
- mudar o grupo de um arquivo para qual o usuário pertence.
-
-
- Retorna &true; se obtiver sucesso; caso contrário retorna
- &false;.
-
-
- Veja também chown e
- chmod.
-
-
-
- Esta função não funciona em sistemas Windows.
-
-
-
-
-
-
-
- chmod
- Modifica as permissões do arquivo
-
-
- Descrição
-
-
- int chmod
- string arquivo
- int modo
-
-
-
- Tenta mudar as permissões do arquivo especificado por
- arquivo para o dado em
- modo.
-
-
- Note que mode não é assumido ser um numero
- octal, então strings (como "g+w") não irá funcionar. Para garantir
- que a operação seja bem sucedide é necessário o prefixo zero (0)
- em mode:
-
-
-chmod ("/algumdir/algumarquivo", 755); // decimal; provavelmente incorreto
-chmod ("/algumdir/algumarquivo", "u+rwx,go+rx"); // string; incorreto
-chmod ("/algumdir/algumarquivo", 0755); // octal; correto valor da permissão
-
-
-
-
- Retorna &verdadeiro; se obtiver sucesso e caso contrário &falso;.
-
-
- Veja também chown e
- chgrp.
-
-
-
- Esta função não funciona em sistemas Windows.
-
-
-
-
-
-
-
- chown
- Modifica o dono do arquivo
-
-
- Descrição
-
-
- int chown
- string arquivo
- mixed usuário
-
-
-
- Tenta modificar o dono do arquivo "arquivo" para o usuário
- "usuário". Somente o superusuário pode modificar o dono de
- um arquivo.
-
-
- Retorna &verdadeiro; se obtiver sucesso e caso contrário &falso;.
-
-
- Veja também chown e
- chmod.
-
-
-
- Esta função não funciona em sistemas Windows.
-
-
-
-
-
-
-
- clearstatcache
- Limpa o cache do file stat
-
-
- Descrição
-
-
- void clearstatcache
-
-
-
-
- Invocando a função do sistema (system call)
- stat ou lstat
- na maior parte do sistema é bem caro. Então, o resultado da ultima
- chamada para qualquer chamada para as funções de status (listadas
- abaixo) é guardada para a ultilização nas possiveis procimas
- chamadas utilizando o mesmo nome de arquivo. Se voce deseja forcar
- um check no status, por exemplo se o arquivo for checado muitas
- vezes e pode mudar ou disaparecer, use esta função para limpar os
- resultados da ultima chamada da memória.
-
-
- Este valor somente reside no cache pelo tempo de somente um pedido.
-
-
- As funções afetadas são stat,
- lstat,
- file_exists,
- is_writable,
- is_readable,
- is_executable,
- is_file,
- is_dir,
- is_link,
- filectime,
- fileatime,
- filemtime,
- fileinode,
- filegroup,
- fileowner,
- filesize,
- filetype, e
- fileperms.
-
-
-
-
-
-
- copy
- Copia arquivo
-
-
- Descrição
-
-
- int copy
- string origem
- string destino
-
-
-
- Faz uma cópia de um arquivo. Retorna &verdadeiro; se a copia é
- obtida com sucesso, caso contrário &falso;.
-
- exemplo do copy
-
-if (!copy($arquivo, $arquivo.'.bak')) {
- print ("erro ao copiar $arquivo...<br>\n");
-}
-
-
-
-
- Veja também: rename.
-
-
-
-
-
-
- delete
- Uma seção dipensável do manual
-
-
- Descrição
-
-
- void delete
- string file
-
-
-
- Esta é uma seção dispensável do manual criada para satisfazer
- as pessoas que estão procurando por unlink
- ou unset no lugar errado.
-
-
- Veja também: unlink para deletar arquivos,
- unset para apagar váriaveis.
-
-
-
-
-
-
- dirname
- Retorna o nome do diretório componente do path
-
-
- Descrição
-
-
- string dirname
- string path
-
-
-
- Dada uma string contendo um path para um arquivo, esta função
- irá retornar o nome do diretório.
-
-
- No Windows, tanto barra (/) quanto a
- barrainvertida (\) são usadas como caracter
- separador no path. Em outros ambientes é utilizado a barra
- (/).
-
-
- exemplo do dirname
-
-$path = "/etc/passwd";
-$file = dirname ($path); // $file is set to "/etc"
-
-
-
-
- Veja também: basename
-
-
-
-
-
-
- disk_free_space
- Retorna o espaço disponivel no diretório.
-
-
- Descrição
-
-
- float disk_free_space
- string diretório
-
-
-
- Dado uma string contendo um diretório, esta função retornará o
- numero de bytes disponíveis no correspondente filesystem ou
- partição de disco.
-
-
-
- exemplo de disk_free_space
-
-$df = disk_free_space("/"); // $df contém o número de bytes.
- // disponível em "/"
-
-
-
-
-
-
-
-
- diskfreespace
- Sinônimo de disk_free_space
-
-
- Descrição
-
-
- float diskfreespace
- string diretório
-
-
-
- Este é um sinônimo obsoleto para a função
- disk_free_space.
- Ultilize aquela função ao invez.
-
-
-
-
-
-
- disk_total_space
- Retorna o tamanho total do diretório
-
-
- Descrição
-
-
- float disk_total_space
- string diretório
-
-
-
- Dado uma string contendo um diretório, esta função retornará o
- numero total de bytes correspondendo ao filesystem ou a partição
- de disco.
-
-
-
- disk_total_space example
-
-$df = disk_total_space("/"); // $df contém o numero total de
- // bytes disponíveis em "/"
-
-
-
-
-
-
-
-
- fclose
- Fecha um ponteiro de arquivo aberto
-
-
- Description
-
-
- bool fclose
- int fp
-
-
-
- O arquivo apontado por fp é fechado.
-
-
- Retorna &verdadeiro; se obtiver sucesso e caso contrário
- &falso;.
-
-
- O ponteiro para o arquivo tem que ser válido e tem que
- apontar para um arquivo aberto por fopen
- ou fsockopen.
-
-
-
-
-
-
- feof
- Testa por fim-de-arquivo (eof) em um ponteiro de arquivo
-
-
- Descrição
-
-
- int feof
- int fp
-
-
-
- Retorna &verdadeiro; se obtiver o ponteiro estiver no fim do arquivo
- (eof) ou um erro ocorrer, caso contrário retorna &falso;.
-
-
- O ponteir para o arquivo tem que ser válido e tem que apontar para
- um arquivo aberto com sucesso por fopen,
- popen, ou fsockopen.
-
-
-
-
-
-
- fflush
- Forca a ida da saida para o arquivo
-
-
- Descrição
-
-
- int fflush
- int fp
-
-
-
- Esta função forca que toda a saída que está no buffer
- para qual o arquivo está apontado pelo
- fp seja escrita.
- Retorna &verdadeiro; se obtiver sucesso e caso contrário
- &falso;.
-
-
- O ponteiro de arquivo tem que ser válido e apontar para
- um arquivo que foi aberto com sucesso por
- fopen, popen,
- ou fsockopen.
-
-
-
-
-
-
- fgetc
- Lê caracter do ponteiro de arquivo
-
-
- Descrição
-
-
- string fgetc
- int fp
-
-
-
- Retorna uma string contendo somente um caracter lido do arquivo
- apontado por fp. Retorna &falso; no fim do arquivo (eof).
-
-
- O ponteiro de arquivo tem que ser válido e apontar para um
- arquivo aberto com sucesso por fopen,
- popen, ou fsockopen.
-
-
- Veja também fread, fopen,
- popen, fsockopen, e
- fgets.
-
-
-
-
-
-
- fgetcsv
-
- Ler uma linha do ponteiro de arquivos e parse por campos CSV
-
-
-
- Descrição
-
-
- array fgetcsv
- int fp
- int comprimento
- string
-
- delimitador
-
-
-
-
-
- Similar à fgets exceto que
- fgetcsv parses a linha que lê por campos
- no formato CSV e retorna um vetor (array)
- contendo os campos lidos. O delimitador dos campos é a virgula,
- a menos que seja especificado com o terceiro parametro que é
- opcional.
-
-
- Fp tem que ser um ponteiro de arquivo
- válido para um arquivo aberto com sucesso por
- fopen, popen,
- ou fsockopen
-
-
- Comprimento tem que ser maior do que a maior linha a ser encontrada
- no arquivo CSV (incluindo caracteres de terminação de linha).
-
-
- fgetcsv retorna &falso; ao encontrar um erro,
- incluindo fim de arquivo (eof).
-
-
- N.B. Uma linha em branco em um arquivo CSV será retornada como um
- vetor contendo um único campo nulo (&null;), e não será tratado
- como um erro.
-
-
-
- exemplo de fgetcsv - Ler e imprimir os conteúdos
- inteiros de um arquivo CSV.
-
-
-$row = 1;
-$fp = fopen ("test.csv","r");
-while ($data = fgetcsv ($fp, 1000, ",")) {
- $num = count ($data);
- print "<p> $num campos na linha $row: <br>";
- $row++;
- for ($c=0; $c<$num; $c++) {
- print $data[$c] . "<br>";
- }
-}
-fclose ($fp);
-
-
-
-
-
-
-
- fgets
- Lê a linha de um ponteiro de arquivo
-
-
- Descrição
-
-
- string fgets
- int fp
- int comprimento
-
-
-
- Retorna uma string com até comprimento - 1 bytes lidos do arquivo
- apontado por fp. A leitura acaba quando comprimento - 1 bytes
- foram lidos, em uma nova linha (newline) (que é incluida no valor
- retornado), ou em um fim de arquivo (eof) (o que acontecer
- primeiro).
-
-
- Se um erro ocorrer, retorna &falso;.
-
-
- Equivocos comuns:
-
-
- Pessoas acostumadas a semantica do fgets em 'C' devem notar a
- diferenca em como o fim do arquivo (eof) é retornado.
-
-
- O ponteiro para o arquivo deve ser válido e deve apontar para um
- arquivo aberto com sucesso por fopen,
- popen, ou
- fsockopen.
-
-
- Um simples exemplo segue:
-
- Lendo um arquivo linha a linha
-
-$fd = fopen ("/tmp/arquivodeentrada.txt", "r");
-while (!feof ($fd)) {
- $buffer = fgets($fd, 4096);
- echo $buffer;
-}
-fclose ($fd);
-
-
-
-
- Veja também fread, fopen,
- popen, fgetc,
- fsockopen, e
- socket_set_timeout.
-
-
-
-
-
-
- fgetss
-
- Gets line from file pointer and strip HTML tags
-
-
-
- Description
-
-
- string fgetss
- int fp
- int length
- string
-
- allowable_tags
-
-
-
-
-
- Identical to fgets, except that fgetss
- attempts to strip any HTML and PHP tags from the text it
- reads.
-
-
- You can use the optional third parameter to specify tags which
- should not be stripped.
-
-
- allowable_tags was added in PHP 3.0.13,
- PHP4B3.
-
-
-
-
- See also fgets, fopen,
- fsockopen, popen, and
- strip_tags.
-
-
-
-
-
-
- file
- Reads entire file into an array
-
-
- Description
-
-
- array file
- string filename
- int
- use_include_path
-
-
-
-
- Identical to readfile, except that
- file returns the file in an array. Each
- element of the array corresponds to a line in the file, with the
- newline still attached.
-
-
- You can use the optional second parameter and set it to "1", if
- you want to search for the file in the include_path, too.
-
-
-
-
-<?php
-// get a web page into an array and print it out
-$fcontents = file ('http://www.php.net');
-while (list ($line_num, $line) = each ($fcontents)) {
- echo "<b>Line $line_num:</b> " . htmlspecialchars ($line) . "<br>\n";
-}
-
-// get a web page into a string
-$fcontents = join ('', file ('http://www.php.net'));
-?>
-
-
-
-
- See also readfile,
- fopen, fsockopen, and
- popen.
-
-
-
-
-
-
-
- file_exists
- Checks whether a file exists
-
-
- Description
-
-
- bool file_exists
- string filename
-
-
-
- Returns &true; if the file specified by
- filename exists; &false; otherwise.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
-
-
-
-
-
- fileatime
- Gets last access time of file
-
-
- Description
-
-
- int fileatime
- string filename
-
-
-
- Returns the time the file was last accessed, or &false; in case of
- an error. The time is returned as a Unix timestamp.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- Note: The atime of a file is supposed to change whenever
- the data blocks of a file are being read. This can be
- costly performancewise when an application regularly
- accesses a very large number of files or directories. Some
- Unix filesystems can be mounted with atime updates disabled
- to increase the performance of such applications; USENET
- news spools are a common example. On such filesystems
- this function will be useless.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
-
-
-
-
- filectime
- Gets inode change time of file
-
-
- Description
-
-
- int filectime
- string filename
-
-
-
- Returns the time the file was last changed, or &false; in case of
- an error. The time is returned as a Unix timestamp.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- Note: In most Unix filesystems, a file is considered
- changed when its inode data is changed; that is, when
- the permissions, owner, group, or other metadata
- from the inode is updated. See also
- filemtime (which is what you want to use
- when you want to create "Last Modified" footers on web pages) and
- fileatime.
-
- Note also that in some Unix texts the ctime of a file is
- referred to as being the creation time of the file. This is wrong.
- There is no creation time for Unix files in most Unix filesystems.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
-
-
-
-
- filegroup
- Gets file group
-
-
- Description
-
-
- int filegroup
- string filename
-
-
-
- Returns the group ID of the owner of the file, or &false; in case
- of an error. The group ID is returned in numerical format, use
- posix_getgrgid to resolve it to a group name.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
-
- This function does not work on Windows systems
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
-
-
-
-
-
- fileinode
- Gets file inode
-
-
- Description
-
-
- int fileinode
- string filename
-
-
-
- Returns the inode number of the file, or &false; in case of an
- error.
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
-
- This function does not work on Windows systems
-
-
-
-
-
-
-
- filemtime
- Gets file modification time
-
-
- Description
-
-
- int filemtime
- string filename
-
-
-
- Returns the time the file was last modified, or &false; in case of
- an error. The time is returned as a Unix timestamp.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
- Note: This function returns the time when the data
- blocks of a file were being written to, that is, the time
- when the content of the file was changed. Use
- date on the result of this function
- to get a printable modification date for use in page footers.
-
-
-
-
-
-
- fileowner
- Gets file owner
-
-
- Description
-
-
- int fileowner
- string filename
-
-
-
- Returns the user ID of the owner of the file, or &false; in case of
- an error. The user ID is returned in numerical format, use
- posix_getpwuid to resolve it to a username.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
-
- This function does not work on Windows systems
-
-
-
-
-
-
-
- fileperms
- Gets file permissions
-
-
- Description
-
-
- int fileperms
- string filename
-
-
-
- Returns the permissions on the file, or &false; in case of an error.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
-
-
-
-
- filesize
- Gets file size
-
-
- Description
-
-
- int filesize
- string filename
-
-
-
- Returns the size of the file, or &false; in case of an error.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
-
-
-
-
- filetype
- Gets file type
-
-
- Description
-
-
- string filetype
- string filename
-
-
-
- Returns the type of the file. Possible values are fifo, char,
- dir, block, link, file, and unknown. Returns &false;
- if an error occurs.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
-
-
-
-
- flock
- Portable advisory file locking
-
-
- Description
-
-
- bool flock
- int fp
- int operation
- int
-
- wouldblock
-
-
-
-
-
- PHP supports a portable way of locking complete files in an
- advisory way (which means all accessing programs have to use the
- same way of locking or it will not work).
-
-
- flock operates on fp
- which must be an open file
- pointer. operation is one of the following
- values:
-
-
-
-
-
- To acquire a shared lock (reader), set
- operation to LOCK_SH (set to 1 prior to
- PHP 4.0.1).
-
-
-
-
- To acquire an exclusive lock (writer), set
- operation to LOCK_EX (set to 2 prior to
- PHP 4.0.1).
-
-
-
-
- To release a lock (shared or exclusive), set
- operation to LOCK_UN (set to 3 prior to
- PHP 4.0.1).
-
-
-
-
- If you don't want flock to block while
- locking, add LOCK_NB (4 prior to PHP 4.0.1) to
- operation.
-
-
-
-
-
- flock allows you to perform a simple
- reader/writer model which can be used on virtually every platform
- (including most Unices and even Windows). The optional 3rd
- argument is set to &true; if the lock would block (EWOULDBLOCK
- errno condition)
-
-
- flock returns &true; on success and &false; on
- error (e.g. when a lock could not be acquired).
-
-
-
- On most operation systems flock is implemented
- at the process level. When using a multithreaded server API like
- ISAPI you cannot rely on flock to protect
- files against other PHP scripts running in parallel threads of the
- same server instance!
-
-
-
-
-
-
-
- fopen
- Opens file or URL
-
-
- Description
-
-
- int fopen
- string filename
- string mode
- int
-
- use_include_path
-
-
-
-
-
- If filename begins with "http://" (not
- case sensitive), an HTTP 1.0 connection is opened to the
- specified server, the page is requested using the HTTP GET
- method, and a file pointer is returned to the beginning
- of the body of the response. A 'Host:' header is sent with the
- request in order to handle name-based virtual hosts.
-
-
- Note that the file pointer allows you to retrieve only the
- body of the response; you cannot
- access the HTTP response header using this function.
-
-
- Versions prior to PHP 4.0.5 do not handle HTTP redirects. Because
- of this, directories must include trailing slashes.
-
-
- If filename begins with "ftp://" (not case
- sensitive), an ftp connection to the specified server is opened
- and a pointer to the requested file is returned. If the server
- does not support passive mode ftp, this will fail. You can open
- files for either reading or writing via ftp (but not both
- simultaneously).
-
-
- If filename is one of "php://stdin",
- "php://stdout", or "php://stderr", the corresponding stdio
- stream will be opened. (This was introduced in PHP 3.0.13;
- in earlier versions, a filename such as "/dev/stdin" or
- "/dev/fd/0" must be used to access the stdio streams.)
-
-
- If filename begins with anything else, the
- file will be opened from the filesystem, and a file pointer to
- the file opened is returned.
-
-
- If the open fails, the function returns &false;.
-
-
- mode may be any of the following:
-
-
-
- 'r' - Open for reading only; place the file pointer at the
- beginning of the file.
-
-
-
-
- 'r+' - Open for reading and writing; place the file pointer at
- the beginning of the file.
-
-
-
-
- 'w' - Open for writing only; place the file pointer at the
- beginning of the file and truncate the file to zero length.
- If the file does not exist, attempt to create it.
-
-
-
-
- 'w+' - Open for reading and writing; place the file pointer at
- the beginning of the file and truncate the file to zero
- length. If the file does not exist, attempt to create it.
-
-
-
-
- 'a' - Open for writing only; place the file pointer at the end
- of the file. If the file does not exist, attempt to create
- it.
-
-
-
-
- 'a+' - Open for reading and writing; place the file pointer at
- the end of the file. If the file does not exist, attempt to
- create it.
-
-
-
-
-
-
- The mode may contain the letter
- 'b'. This is useful only on systems which differentiate between
- binary and text files (i.e. Windows. It's useless on Unix).
- If not needed, this will be ignored.
-
-
-
- You can use the optional third parameter and set it to "1", if
- you want to search for the file in the include_path, too.
-
-
-
- fopen example
-
-$fp = fopen ("/home/rasmus/file.txt", "r");
-$fp = fopen ("/home/rasmus/file.gif", "wb");
-$fp = fopen ("http://www.php.net/", "r");
-$fp = fopen ("ftp://user:password <email protected>/", "w");
-
-
-
-
- If you are experiencing problems with reading and writing to
- files and you're using the server module version of PHP, remember
- to make sure that the files and directories you're using are
- accessible to the server process.
-
-
- On the Windows platform, be careful to escape any backslashes
- used in the path to the file, or use forward slashes.
-
-
-$fp = fopen ("c:\\data\\info.txt", "r");
-
-
-
-
- See also fclose,
- fsockopen,
- socket_set_timeout, and
- popen.
-
-
-
-
-
-
- fpassthru
-
- Output all remaining data on a file pointer
-
-
-
- Description
-
-
- int fpassthru
- int fp
-
-
-
- Reads to EOF on the given file pointer and writes the results to
- standard output.
-
-
- If an error occurs, fpassthru returns
- &false;.
-
-
- The file pointer must be valid, and must point to a file
- successfully opened by fopen,
- popen, or fsockopen.
- The file is closed when fpassthru is done
- reading it (leaving fp useless).
-
-
- If you just want to dump the contents of a file to stdout you may
- want to use the readfile, which saves you
- the fopen call.
-
-
- See also readfile,
- fopen, popen, and
- fsockopen
-
-
-
-
-
-
- fputs
- Writes to a file pointer
-
-
- Description
-
-
- int fputs
- int fp
- string str
- int
-
- length
-
-
-
-
-
- fputs is an alias to
- fwrite, and is identical in every way. Note
- that the length parameter is optional and
- if not specified the entire string will be written.
-
-
-
-
-
-
- fread
- Binary-safe file read
-
-
- Description
-
-
- string fread
- int fp
- int length
-
-
-
- fread reads up to
- length bytes from the file pointer
- referenced by fp. Reading stops when
- length bytes have been read or EOF is
- reached, whichever comes first.
-
-
-
-
-// get contents of a file into a string
-$filename = "/usr/local/something.txt";
-$fd = fopen ($filename, "r");
-$contents = fread ($fd, filesize ($filename));
-fclose ($fd);
-
-
-
-
-
- On systems which differentiate between binary and text files
- (i.e. Windows) the file must be opened with 'b' included in
- fopen mode parameter.
-
-
-
-
-
-$filename = "c:\\files\\somepic.gif";
-$fd = fopen ($filename, "rb");
-$contents = fread ($fd, filesize ($filename));
-fclose ($fd);
-
-
-
-
- See also fwrite, fopen,
- fsockopen, popen,
- fgets, fgetss,
- fscanf, file, and
- fpassthru.
-
-
-
-
-
-
- fscanf
- Parses input from a file according to a format
-
-
- Description
-
-
- mixed fscanf
- int handle
- string format
- string
- var1...
-
-
-
-
- The function fscanf is similar to
- sscanf, but it takes its input from a file
- associated with handle and interprets the
- input according to the specified
- format. If only two parameters were passed
- to this function, the values parsed will be returned as an array.
- Otherwise, if optional parameters are passed, the function will
- return the number of assigned values. The optional parameters
- must be passed by reference.
-
- fscanf Example
-
-$fp = fopen ("users.txt","r");
-while ($userinfo = fscanf ($fp, "%s\t%s\t%s\n")) {
- list ($name, $profession, $countrycode) = $userinfo;
- //... do something with the values
-}
-fclose($fp);
-
-
-
- users.txt
-
-javier argonaut pe
-hiroshi sculptor jp
-robert slacker us
-luigi florist it
-
-
-
-
- See also fread, fgets,
- fgetss, sscanf,
- printf, and sprintf.
-
-
-
-
-
-
- fseek
- Seeks on a file pointer
-
-
- Description
-
-
- int fseek
- int fp
- int offset
- int
- whence
-
-
-
-
- Sets the file position indicator for the file referenced by
- fp.The new position, measured in bytes
- from the beginning of the file, is obtained by adding
- offset to the position specified by
- whence, whose values are defined as
- follows:
-
- SEEK_SET - Set position equal to
- offset bytes.SEEK_CUR -
- Set position to current location plus
- offset.SEEK_END - Set
- position to end-of-file plus
- offset.
-
-
- If whence is not specified, it is assumed to be
- SEEK_SET.
-
-
- Upon success, returns 0; otherwise, returns -1. Note that seeking
- past EOF is not considered an error.
-
-
- May not be used on file pointers returned by
- fopen if they use the "http://" or "ftp://"
- formats.
-
-
-
- The whence argument was added after PHP 4.0 RC1.
-
-
-
- See also ftell and
- rewind.
-
-
-
-
-
-
- fstat
-
- Gets information about a file using an open file pointer
-
-
-
- Description
-
-
- array fstat
- int fp
-
-
-
- Gathers the statistics of the file opened by the file
- pointer fp. This function is similar to the
- stat function except that it operates
- on an open file pointer instead of a filename.
-
-
- Returns an array with the statistics of the file with the
- following elements:
-
- device
- inode
- number of links
- user id of owner
- group id owner
- device type if inode device *
- size in bytes
- time of last access
- time of last modification
- time of last change
- blocksize for filesystem I/O *
- number of blocks allocated
-
- * - only valid on systems supporting the st_blksize type--other
- systems (i.e. Windows) return -1
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
-
-
-
-
- ftell
- Tells file pointer read/write position
-
-
- Description
-
-
- int ftell
- int fp
-
-
-
- Returns the position of the file pointer referenced by fp; i.e.,
- its offset into the file stream.
-
-
- If an error occurs, returns &false;.
-
-
- The file pointer must be valid, and must point to a file
- successfully opened by fopen or
- popen.
-
-
- See also fopen, popen,
- fseek and rewind.
-
-
-
-
-
-
- ftruncate
-
- Truncates a file to a given length.
-
-
-
- Description
-
-
- int ftruncate
- int fp
- int size
-
-
-
- Takes the filepointer, fp, and truncates the file to length, size.
- This function returns &true; on success and &false; on failure.
-
-
-
-
-
-
- fwrite
- Binary-safe file write
-
-
- Description
-
-
- int fwrite
- int fp
- string string
- int
-
- length
-
-
-
-
-
- fwrite writes the contents of
- string to the file stream pointed to by
- fp. If the length
- argument is given, writing will stop after
- length bytes have been written or the end
- of string is reached, whichever comes
- first.
-
-
- Note that if the length argument is given,
- then the magic_quotes_runtime
- configuration option will be ignored and no slashes will be
- stripped from string.
-
-
-
- On systems which differentiate between binary and text files
- (i.e. Windows) the file must be opened with 'b' included in
- fopen mode parameter.
-
-
-
- See also fread, fopen,
- fsockopen, popen, and
- fputs.
-
-
-
-
-
-
- set_file_buffer
-
- Sets file buffering on the given file pointer
-
-
-
- Description
-
-
- int set_file_buffer
- int fp
- int buffer
-
-
-
- Output using fwrite is normally buffered at
- 8K. This means that if there are two processess wanting to write
- to the same output stream (a file), each is paused after 8K of
- data to allow the other to write. set_file_buffer
- sets the buffering for write operations on the given filepointer
- fp to buffer bytes.
- If buffer is 0 then write operations are
- unbuffered. This ensures that all writes with
- fwrite are completed before other processes
- are allowed to write to that output stream.
-
-
- The function returns 0 on success, or EOF if the request cannot
- be honored.
-
-
- The following example demonstrates how to use
- set_file_buffer to create an unbuffered stream.
-
- set_file_buffer example
-
-$fp=fopen($file, "w");
-if($fp){
- set_file_buffer($fp, 0);
- fputs($fp, $output);
- fclose($fp);
-}
-
-
-
-
-
- See also fopen, fwrite.
-
-
-
-
-
-
- is_dir
- Tells whether the filename is a directory
-
-
- Description
-
-
- bool is_dir
- string filename
-
-
-
- Returns &true; if the filename exists and is a directory.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
- See also is_file and
- is_link.
-
-
-
-
-
-
- is_executable
- Tells whether the filename is executable
-
-
- Description
-
-
- bool is_executable
- string filename
-
-
-
- Returns &true; if the filename exists and is executable.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
- See also is_file and
- is_link.
-
-
-
-
-
-
- is_file
-
- Tells whether the filename is a regular file
-
-
-
- Description
-
-
- bool is_file
- string filename
-
-
-
- Returns &true; if the filename exists and is a regular file.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- See also is_dir and
- is_link.
-
-
-
-
-
-
- is_link
-
- Tells whether the filename is a symbolic link
-
-
-
- Description
-
-
- bool is_link
- string filename
-
-
-
- Returns &true; if the filename exists and is a symbolic link.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- See also is_dir and
- is_file.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
-
- This function does not work on Windows systems
-
-
-
-
-
-
-
- is_readable
-
- Tells whether the filename is readable
-
-
-
- Description
-
-
- bool is_readable
- string filename
-
-
-
- Returns &true; if the filename exists and is readable.
-
-
- Keep in mind that PHP may be accessing the file as the user
- id that the web server runs as (often 'nobody'). Safe mode
- limitations are not taken into account.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
- See also is_writable.
-
-
-
-
-
-
- is_writable
- Tells whether the filename is writable
-
-
- Description
-
-
- bool is_writable
- string filename
-
-
-
- Returns &true; if the filename exists and is writable. The
- filename argument may be a directory name allowing you to check
- if a directory is writeable.
-
-
- Keep in mind that PHP may be accessing the file as the user id
- that the web server runs as (often 'nobody'). Safe mode
- limitations are not taken into account.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
- This function will not work on remote files; the file to
- be examined must be accessible via the server's filesystem.
-
-
- See also is_readable.
-
-
-
-
-
-
- is_writeable
- Tells whether the filename is writable
-
-
- Description
-
-
- bool is_writeable
- string filename
-
-
-
- This is an alias for is_writable
-
-
-
-
-
-
- is_uploaded_file
- Tells whether the file was uploaded via HTTP POST.
-
-
- Description
-
-
- bool is_uploaded_file
- string filename
-
-
-
-
- This function is available only in versions of PHP 3 after PHP
- 3.0.16, and in versions of PHP 4 after 4.0.2.
-
-
-
- Returns &true; if the file named by filename was
- uploaded via HTTP POST. This is useful to help ensure that a
- malicious user hasn't tried to trick the script into working on
- files upon which it should not be working--for instance,
- /etc/passwd.
-
-
-
- This sort of check is especially important if there is any chance
- that anything done with uploaded files could reveal their
- contents to the user, or even to other users on the same
- system.
-
-
-
- See also move_uploaded_file, and the section
- Handling file uploads
- for a simple usage example.
-
-
-
-
-
-
- link
- Create a hard link
-
-
- Description
-
-
- int link
- string target
- string link
-
-
-
- link creates a hard link.
-
- See also the symlink to create soft links,
- and readlink along with
- linkinfo.
-
-
-
- This function does not work on Windows systems
-
-
-
-
-
-
-
- linkinfo
- Gets information about a link
-
-
- Description
-
-
- int linkinfo
- string path
-
-
-
- linkinfo returns the st_dev field of the
- UNIX C stat structure returned by the lstat system call. This
- function is used to verify if a link (pointed to by
- path) really exists (using the same method
- as the S_ISLNK macro defined in stat.h). Returns 0 or &false; in
- case of error.
-
-
- See also symlink, link,
- and readlink.
-
-
-
- This function does not work on Windows systems
-
-
-
-
-
-
-
- mkdir
- Makes directory
-
-
- Description
-
-
- int mkdir
- string pathname
- int mode
-
-
-
- Attempts to create the directory specified by pathname.
-
-
- Note that you probably want to specify the mode as an
- octal number, which means it should have a leading zero.
- The mode is also modified by the current umask, which you
- can change using umask.
-
-
-mkdir ("/path/to/my/dir", 0700);
-
-
-
-
- Returns &true; on success and &false; on failure.
-
-
- See also rmdir.
-
-
-
-
-
-
- move_uploaded_file
- Moves an uploaded file to a new location.
-
-
- Description
-
-
- bool move_uploaded_file
- string filename
- string destination
-
-
-
-
- This function is available only in versions of PHP 3 after PHP
- 3.0.16, and in versions of PHP 4 after 4.0.2.
-
-
-
- This function checks to ensure that the file designated by
- filename is a valid upload file (meaning
- that it was uploaded via PHP's HTTP POST upload mechanism). If
- the file is valid, it will be moved to the filename given by
- destination.
-
-
-
- If filename is not a valid upload file,
- then no action will occur, and
- move_uploaded_file will return
- &false;.
-
-
-
- If filename is a valid upload file, but
- cannot be moved for some reason, no action will occur, and
- move_uploaded_file will return
- &false;. Additionally, a warning will be issued.
-
-
-
- This sort of check is especially important if there is any chance
- that anything done with uploaded files could reveal their
- contents to the user, or even to other users on the same
- system.
-
-
- ¬e.sm.uidcheck;
-
-
- See also is_uploaded_file, and the section
- Handling file uploads
- for a simple usage example.
-
-
-
-
-
-
- parse_ini_file
- Parse a configuration file
-
-
- Description
-
-
- array parse_ini_file
- string filename
- bool
-
- process_sections
-
-
-
-
-
- parse_ini_file loads in the
- ini file specified in filename,
- and returns the settings in it in an associative array.
- By setting the last process_sections
- parameter to &true;, you get a multidimensional array, with
- the section names and settings included. The default
- for process_sections is &false;
-
-
-
- This function has nothing to do with the
- php.ini file. It is already processed,
- the time you run your script. This function can be used to
- read in your own application's configuration files.
-
-
-
- The structure of the ini file is similar to that of
- the php.ini's.
-
-
-
- Contents of sample.ini
-
-; This is a sample configuration file
-; Comments start with ';', as in php.ini
-
-[first_section]
-one = 1
-five = 5
-
-[second_section]
-path = /usr/local/bin
-
-
-
-
-
- parse_ini_file example
-
-
-]]>
-
-
-
-
- Would produce:
-
-
-Array
-(
- [one] => 1
- [five] => 5
- [path] => /usr/local/bin
-)
-Array
-(
- [first_section] => Array
- (
- [one] => 1
- [five] => 5
- )
-
- [second_section] => Array
- (
- [path] => /usr/local/bin
- )
-
-)
-
-
-
-
-
-
-
-
- pathinfo
- Returns information about a file path
-
-
- Description
-
-
- array pathinfo
- string path
-
-
-
- pathinfo returns an associative array
- containing information about path. The
- following array elements are returned:
- dirname, basename
- and extension.
-
-
-
- pathinfo Example
-
-<?php
-
-$path_parts = pathinfo("/www/htdocs/index.html");
-
-echo $path_parts["dirname"] . "\n";
-echo $path_parts["basename"] . "\n";
-echo $path_parts["extension"] . "\n";
-
-?>
-
-
-
-
- Would produce:
-
-
-/www/htdocs
-index.html
-html
-
-
-
-
- See also dirname,
- basename, parse_url
- and realpath.
-
-
-
-
-
-
- pclose
- Closes process file pointer
-
-
- Description
-
-
- int pclose
- int fp
-
-
-
- Closes a file pointer to a pipe opened by
- popen.
-
-
- The file pointer must be valid, and must have been returned by a
- successful call to popen.
-
-
- Returns the termination status of the process that was
- run.
-
-
- See also popen.
-
-
-
-
-
-
- popen
- Opens process file pointer
-
-
- Description
-
-
- int popen
- string command
- string mode
-
-
-
- Opens a pipe to a process executed by forking the command given
- by command.
-
-
- Returns a file pointer identical to that returned by
- fopen, except that it is unidirectional (may
- only be used for reading or writing) and must be closed with
- pclose. This pointer may be used with
- fgets, fgetss, and
- fputs.
-
-
- If an error occurs, returns &false;.
-
-
-
-
-$fp = popen ("/bin/ls", "r");
-
-
-
-
- See also pclose.
-
-
-
-
-
-
- readfile
- Outputs a file
-
-
- Description
-
-
- int readfile
- string filename
- int
-
- use_include_path
-
-
-
-
-
- Reads a file and writes it to standard output.
-
-
- Returns the number of bytes read from the file. If an error
- occurs, &false; is returned and unless the function was called as
- <email protected>, an error message is printed.
-
-
- If filename begins with "http://"
- (not case sensitive), an HTTP 1.0 connection is opened to the
- specified server and the text of the response is written to
- standard output.
-
-
- Versions prior to PHP 4.0.5 do not handle HTTP redirects. Because
- of this, directories must include trailing slashes.
-
-
- If filename begins with "ftp://"
- (not case sensitive), an ftp connection to the specified server is
- opened and the requested file is written to standard output. If the server
- does not support passive mode ftp, this will fail.
-
-
- If filename begins with neither
- of these strings, the file will be opened from the filesystem and
- its contents written to standard output.
-
-
- You can use the optional second parameter and set it to "1", if
- you want to search for the file in the include_path, too.
-
-
- See also fpassthru,
- file, fopen,
- include, require, and
- virtual.
-
-
-
-
-
-
- readlink
- Returns the target of a symbolic link
-
-
- Description
-
-
- string readlink
- string path
-
-
-
- readlink does the same as the readlink C
- function and returns the contents of the symbolic link path or 0
- in case of error.
-
-
- See also symlink,
- readlink and
- linkinfo.
-
-
-
- This function does not work on Windows systems
-
-
-
-
-
-
-
- rename
- Renames a file
-
-
- Description
-
-
- int rename
- string oldname
- string newname
-
-
-
- Attempts to rename oldname to
- newname.
-
-
- Returns &true; on success and &false; on failure.
-
-
-
-
-
-
- rewind
- Rewind the position of a file pointer
-
-
- Description
-
-
- int rewind
- int fp
-
-
-
- Sets the file position indicator for fp to the beginning of the
- file stream. If an error occurs, returns 0.
- The file pointer must be valid, and must point to a file
- successfully opened by fopen.
-
-
- See also fseek and
- ftell.
-
-
-
-
-
-
-
- rmdir
- Removes directory
-
-
- Description
-
-
- int rmdir
- string dirname
-
-
-
- Attempts to remove the directory named by pathname. The directory
- must be empty, and the relevant permissions must permit.
- this.
-
-
- If an error occurs, returns 0.
-
-
- See also mkdir.
-
-
-
-
-
-
- stat
- Gives information about a file
-
-
- Description
-
-
- array stat
- string filename
-
-
-
- Gathers the statistics of the file named by filename.
-
-
- Returns an array with the statistics of the file with the
- following elements:
-
- device
- inode
- inode protection mode
- number of links
- user id of owner
- group id owner
- device type if inode device *
- size in bytes
- time of last access
- time of last modification
- time of last change
- blocksize for filesystem I/O *
- number of blocks allocated
-
- * - only valid on systems supporting the st_blksize type--other
- systems (i.e. Windows) return -1.
-
-
- Returns &false; in case of error.
-
-
- stat doesn't handle URL as does fopen.
-
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
-
-
-
-
- lstat
-
- Gives information about a file or symbolic link
-
-
-
- Description
-
-
- array lstat
- string filename
-
-
-
- Gathers the statistics of the file or symbolic link named by
- filename. This function is identical to the
- stat function except that if the
- filename parameter is a symbolic link, the
- status of the symbolic link is returned, not the status of the
- file pointed to by the symbolic link.
-
-
- Returns an array with the statistics of the file with the
- following elements:
-
- device
- inode
- inode protection mode
- number of links
- user id of owner
- group id owner
- device type if inode device *
- size in bytes
- time of last access
- time of last modification
- time of last change
- blocksize for filesystem I/O *
- number of blocks allocated
-
- * - only valid on systems supporting the st_blksize type--other
- systems (i.e. Windows) return -1
-
- The results of this function are cached. See
- clearstatcache for more details.
-
-
-
-
-
-
- realpath
- Returns canonicalized absolute pathname
-
-
- Description
-
-
- string realpath
- string path
-
-
-
- realpath expands all symbolic links and
- resolves references to '/./', '/../' and extra '/' characters in
- the input path and return the canonicalized
- absolute pathname. The resulting path will have no symbolic link,
- '/./' or '/../' components.
-
-
-
- realpath example
-
-$real_path = realpath ("../../index.php");
-
-
-
-
-
-
-
-
- symlink
- Creates a symbolic link
-
-
- Description
-
-
- int symlink
- string target
- string link
-
-
-
- symlink creates a symbolic link
- from the existing target with
- the specified name link.
-
-
- See also link to create hard links,
- and readlink along with
- linkinfo.
-
-
-
- This function does not work on Windows systems.
-
-
-
-
-
-
-
- tempnam
- Creates unique file name
-
-
- Description
-
-
- string tempnam
- string dir
- string prefix
-
-
-
- Creates a unique temporary filename in the specified directory.
- If the directory does not exist, tempnam may
- generate a filename in the system's temporary directory.
-
-
- Prior to PHP 4.0.6, the behaviour of the
- tempnam function was system dependent. On
- Windows the TMP environment variable will override the
- dir parameter, on Linux the TMPDIR
- environment variable has precedence, while SVR4 will always use
- your dir parameter if the directory it
- points to exists. Consult your system documentation on the
- tempnam(3) function if in doubt.
-
-
- Returns the new temporary filename, or the &null; string on
- failure.
-
- tempnam example
-
-$tmpfname = tempnam ("/tmp", "FOO");
-
-
-
-
-
- This function's behavior changed in 4.0.3. The temporary file is also
- created to avoid a race condition where the file might appear in the
- filesystem between the time the string was generated and before the
- the script gets around to creating the file.
-
-
-
- See also tmpfile.
-
-
-
-
-
-
- tmpfile
- Creates a temporary file
-
-
- Description
-
-
- int tmpfile
-
-
-
-
- Creates a temporary file with an unique name in write mode,
- returning a file handle similar to the one returned by
- fopen.
- The file is automatically removed when closed (using
- fclose), or when the script ends.
-
-
- For details, consult your system documentation on the
- tmpfile(3) function, as well as the
- stdio.h header file.
-
-
- See also tempnam.
-
-
-
-
-
-
-
- touch
- Sets modification time of file
-
-
- Description
-
-
- int touch
- string filename
- int
-
- time
-
-
-
-
-
- Attempts to set the modification time of the file named by
- filename to the value given by time. If the option time is not
- given, uses the present time.
-
-
- If the file does not exist, it is created.
-
-
- Returns &true; on success and &false; otherwise.
-
- touch example
-
-if (touch ($FileName)) {
- print "$FileName modification time has been
- changed to todays date and time";
-} else {
- print "Sorry Could Not change modification time of $FileName";
-}
-
-
-
-
-
-
-
-
- umask
- Changes the current umask
-
-
- Description
-
-
- int umask
- int mask
-
-
-
- umask sets PHP's umask to mask & 0777 and
- returns the old umask. When PHP is being used as a server module,
- the umask is restored when each request is finished.
-
-
-