PHP Filesystem-funktioner
- Föregående sida PHP Error
- Nästa sida PHP Filter
PHP Filsystem Introduktion
Filsystemsfunktioner låter dig komma åt och manipulera filsystemet.
Installera
Filsystemsfunktioner är en del av PHP-kärnan. Dessa funktioner behöver inte installeras för att användas.
Körningskonfiguration
Beteendet för filsystemfunktioner påverkas av inställningar i php.ini.
Filsystemskonfigurationsalternativ:
Namn | Standard | Beskrivning | Ändringsbart |
---|---|---|---|
allow_url_fopen | "1" |
Detta alternativ aktiverar URL-formen av fopen-omhöljningsprotokollet, vilket gör det möjligt att komma åt URL-objekt som exempelvis filer. Standardens omhöljningsprotokoll erbjuder åtkomst till fjärrfiler via ftp- och http-protokoll, vissa utökade bibliotek som zlib kan registrera fler omhöljningsprotokoll. (Tillgängligt från PHP 4.0.4-versionen och senare.) |
PHP_INI_SYSTEM |
user_agent | NULL |
Definiera User-Agent som PHP skickar. (Available since PHP 4.3.0 version.) |
PHP_INI_ALL |
default_socket_timeout | "60" |
Standard timeout för streamar baserade på socket (sekunder). (Available since PHP 4.3.0 version.) |
PHP_INI_ALL |
from | "" | Definiera lösenordet för anonym FTP (din e-postadress). | PHP_INI_ALL |
auto_detect_line_endings | "0" |
When set to On, PHP will check if the line terminator in the data obtained through fgets() and file() is in accordance with the Unix, MS-DOS, or Macintosh habit. This allows PHP to interact with Macintosh systems, but the default value is Off because there is a slight performance loss when detecting the EOL habit of the first line, and people who use the carriage return symbol as a field separator in Unix systems will encounter downwardly incompatible behavior. (Available since PHP 4.3.0 version.) |
PHP_INI_ALL |
Unix / Windows Compatibility
When specifying paths on Unix platforms, the forward slash (/) is used as a directory separator. On Windows platforms, both forward slash (/) and backslash (\) can be used.
PHP Filesystem-funktioner
PHP:Indicate the earliest PHP version that supports this function.
Function | Beskrivning | PHP |
---|---|---|
basename() | Return the file name part of the path. | 3 |
chgrp() | Change the file group. | 3 |
chmod() | Change the file mode. | 3 |
chown() | Change the file owner. | 3 |
clearstatcache() | Clear the file status cache. | 3 |
copy() | Copy a file. | 3 |
delete() | See unlink() Or unset(). | |
dirname() | Return the directory name part of the path. | 3 |
disk_free_space() | Return the available space in a directory. | 4 |
disk_total_space() | Return the total disk capacity of a directory. | 4 |
diskfreespace() | disk_free_space() alias. | 3 |
fclose() | Close an open file. | 3 |
feof() | Test if the file pointer is at the end of the file. | 3 |
fflush() | Output the contents of the open file buffer. | 4 |
fgetc() | Return a character from an open file. | 3 |
fgetcsv() | Parse a line from an open file, validate CSV fields. | 3 |
fgets() | Return a line from an open file. | 3 |
fgetss() | Read a line from an open file and filter out HTML and PHP tags. | 3 |
file() | Read a file into an array. | 3 |
file_exists() | Check if a file or directory exists. | 3 |
file_get_contents() | Read a file into a string. | 4 |
file_put_contents() | Write a string to a file. | 5 |
fileatime() | Return the last access time of the file. | 3 |
filectime() | Return the last modified time of the file. | 3 |
filegroup() | Returnera filens grupp-ID. | 3 |
fileinode() | Returnera filens inode-nummer. | 3 |
filemtime() | Returnera filens senaste ändringsdatum. | 3 |
fileowner() | Filens användar-ID (ägare). | 3 |
fileperms() | Returnera filens rättigheter. | 3 |
filesize() | Returnera filstorleken. | 3 |
filetype() | Returnera filtypen. | 3 |
flock() | Lås eller frigör filen. | 3 |
fnmatch() | Matcha filnamn eller strängar enligt det angivna mönstret. | 4 |
fopen() | Öppna en fil eller URL. | 3 |
fpassthru() | Läs data från den öppna filen till EOF och skriv resultaten till utdatabufferten. | 3 |
fputcsv() | Formatera raden som CSV och skriv till en öppen fil. | 5 |
fputs() | fwrite() alias. | 3 |
fread() | Läs den öppna filen. | 3 |
fscanf() | Analysera inmatning enligt det angivna formatet. | 4 |
fseek() | Positionera i den öppna filen. | 3 |
fstat() | Returnera information om en öppen fil. | 4 |
ftell() | Returnera läshållarens läs/skrivposition. | 3 |
ftruncate() | Klipper filen till den angivna längden. | 4 |
fwrite() | Skriv till fil. | 3 |
glob() | Returnera en array som innehåller filnamn/kataloger som matchar det angivna mönstret. | 4 |
is_dir() | Avgör om det angivna filnamnet är en katalog. | 3 |
is_executable() | Avgör om filen är körbar. | 3 |
is_file() | Avgör om den angivna filen är en vanlig fil. | 3 |
is_link() | Avgör om den angivna filen är en länk. | 3 |
is_readable() | Avgör om filen är läsbare. | 3 |
is_uploaded_file() | Avgör om filen har laddats upp via HTTP POST. | 3 |
is_writable() | Avgör om filen är skrivbar. | 4 |
is_writeable() | is_writable() alias. | 3 |
link() | Skapa en hårdlänk. | 3 |
linkinfo() | Returnera information om en hårdlänk. | 3 |
lstat() | Returnera information om fil eller symbolisk länk. | 3 |
mkdir() | Skapa en katalog. | 3 |
move_uploaded_file() | Flytta den uppladdade filen till en ny plats. | 4 |
parse_ini_file() | Analysera en konfigurationsfil. | 4 |
pathinfo() | Returnera information om filväg. | 4 |
pclose() | Stäng process som öppnats med popen(). | 3 |
popen() | popen() | 3 |
Öppna ett process. | readfile() | 3 |
Läs en fil och skriv ut till utdatabufferten. | Returnera målet för en symbolisk länk. | 3 |
realpath() | Returnera det absoluta filnamnet. | 4 |
rename() | Byt namn på fil eller katalog. | 3 |
rewind() | Återställ filpekarens position. | 3 |
rmdir() | Ta bort tomma kataloger. | 3 |
set_file_buffer() | Ställ in buffertstorleken för öppnade filer. | 3 |
stat() | Returnera information om filen. | 3 |
symlink() | Skapa en symbolisk länk. | 3 |
tempnam() | Skapa en unik temporär fil. | 3 |
tmpfile() | Skapa en temporär fil. | 3 |
touch() | Ställ in filens åtkomst- och ändringsdatum. | 3 |
umask() | Ändra filens filrättigheter. | 3 |
unlink() | Ta bort filer. | 3 |
PHP Filesystem-konstanter
PHP:Indikerar den tidigaste PHP-version som stöder den här konstanten.
Konstanter | Beskrivning | PHP |
---|---|---|
GLOB_BRACE | ||
GLOB_ONLYDIR | ||
GLOB_MARK | ||
GLOB_NOSORT | ||
GLOB_NOCHECK | ||
GLOB_NOESCAPE | ||
PATHINFO_DIRNAME | ||
PATHINFO_BASENAME | ||
PATHINFO_EXTENSION | ||
FILE_USE_INCLUDE_PATH | ||
FILE_APPEND | ||
FILE_IGNORE_NEW_LINES | ||
FILE_SKIP_EMPTY_LINES |
- Föregående sida PHP Error
- Nästa sida PHP Filter