XL. System plików
Wymagania
Żadne zewnętrzne biblioteki nie są potrzebne do zbudowania tego rozszeżenia, jeśli jednak potrzebujesz PHP z obsługą LFS (dużych plików) na Linuksie, musisz mieć nowy glibc i skompilować PHP z następującą flagą kompilatora: -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64.
Instalacja
By używać tych funkcji, nie trzeba niczego instalować. Są one częścią jądra PHP.
Konfiguracja uruchomieniowa
Na działanie tych funcji wpływają ustawienia zawarte w pliku php.ini.
Tabela 1. Filesystem and Streams Configuration Options
Name | Default | Changeable | Changelog |
---|---|---|---|
allow_url_fopen | "1" | PHP_INI_SYSTEM | PHP_INI_ALL in PHP <= 4.3.4. Available since PHP 4.0.4. |
allow_url_include | "0" | PHP_INI_SYSTEM | Available since PHP 5.2.0. |
user_agent | NULL | PHP_INI_ALL | Available since PHP 4.3.0. |
default_socket_timeout | "60" | PHP_INI_ALL | Available since PHP 4.3.0. |
from | "" | PHP_INI_ALL | |
auto_detect_line_endings | "0" | PHP_INI_ALL | Available since PHP 4.3.0. |
Oto krótkie wyjaśnienie dyrektyw konfiguracji.
allow_url_fopen
booleanThis option enables the URL-aware fopen wrappers that enable accessing URL object like files. Default wrappers are provided for the access of remote files using the ftp or http protocol, some extensions like zlib may register additional wrappers.
Notatka: This setting can only be set in php.ini due to security reasons.
Notatka: This option was introduced immediately after the release of version 4.0.3. For versions up to and including 4.0.3 you can only disable this feature at compile time by using the configuration switch
--disable-url-fopen-wrapper
.Ostrzeżenie On Windows versions prior to PHP 4.3.0, the following functions do not support remote file accessing: include(), include_once(), require(), require_once() and the imagecreatefromXXX functions in the Materiały źródłowe LXIII, Image Functions extension.
allow_url_include
booleanThis option allows the use of URL-aware fopen wrappers with the following functions: include(), include_once(), require(), require_once().
Notatka: This setting requires allow_url_fopen to be on.
user_agent
stringDefine the user agent for PHP to send.
default_socket_timeout
integerDefault timeout (in seconds) for socket based streams.
Notatka: This configuration option was introduced in PHP 4.3.0
from
stringDefine the anonymous ftp password (your email address).
auto_detect_line_endings
booleanWhen turned on, PHP will examine the data read by fgets() and file() to see if it is using Unix, MS-Dos or Macintosh line-ending conventions.
This enables PHP to interoperate with Macintosh systems, but defaults to Off, as there is a very small performance penalty when detecting the EOL conventions for the first line, and also because people using carriage-returns as item separators under Unix systems would experience non-backwards-compatible behaviour.
Notatka: This configuration option was introduced in PHP 4.3.0
Stałe predefiniowane
Poniższe stałe są zdefiniowane w tym rozszerzeniu i stają się dostępne, gdy rozszerzenie jest dokompilowane do PHP, lub załadowane dynamicznie przy starcie.
- GLOB_BRACE (integer)
- GLOB_ONLYDIR (integer)
- GLOB_MARK (integer)
- GLOB_NOSORT (integer)
- GLOB_NOCHECK (integer)
- GLOB_NOESCAPE (integer)
- PATHINFO_DIRNAME (integer)
- PATHINFO_BASENAME (integer)
- PATHINFO_EXTENSION (integer)
- PATHINFO_FILENAME (integer)
Od PHP 5.2.0.
- FILE_USE_INCLUDE_PATH (integer)
- FILE_APPEND (integer)
- FILE_IGNORE_NEW_LINES (integer)
- FILE_SKIP_EMPTY_LINES (integer)
Patrz także
Związane z tym działem funkcje, znajdziesz w rozdziale Katalog i Wykonywanie programów.
Listę wraz z opisem różnych wrapperów URL, które mogą zostać użyte jako zdalne pliki, znajdziesz tu Dodatek M.
- Spis treści
- basename -- Zwraca nazwę pliku, będącego składową ścieżki
- chgrp -- Zmienia grupÄ™ pliku
- chmod -- Zmienia prawa dostępu do pliku
- chown -- Zmienia właściciela pliku
- clearstatcache -- Czyści bufor statusu pliku
- copy -- Kopiuje plik
- delete -- Zobacz unlink() lub unset()
- dirname -- Zwraca nazwę katalogu, będącego składową ścieżki
- disk_free_space -- Zwraca ilość wolnego miejsca w katalogu
- disk_total_space -- Zwraca całkowity rozmiar katalogu
- diskfreespace -- Alias dla disk_free_space()
- fclose -- Zamyka otwarty wskaźnik pliku
- feof -- Sprawdza czy wskaźnik pliku jest na końcu pliku (EOF)
- fflush -- Przekierowuje wyjście do pliku
- fgetc -- Pobiera znak ze wskaźnika pliku
- fgetcsv -- Pobiera liniÄ™ ze wskanika pliku i przetwarza na pola CSV
- fgets -- Pobiera linię ze wskaźnika pliku
- fgetss -- Pobiera linię ze wskaźnika pliku i usuwa tagi HTML
- file_exists -- Sprawdza czy plik lub katalog istnieje
- file_get_contents -- Reads entire file into a string
- file_put_contents -- Write a string to a file
- file -- Czyta całą zawartość pliku do tablicy
- fileatime -- Pobiera ostatni czas dostępu do pliku
- filectime -- Pobiera i-węzłowy czas zmiany pliku
- filegroup -- Pobiera grupÄ™ pliku
- fileinode -- Pobiera i-węzeł pliku
- filemtime -- Pobiera czas ostatniej modyfikacji pliku
- fileowner -- Pobiera właściciela pliku
- fileperms -- Pobiera prawa dostępu pliku
- filesize -- Pobiera rozmiar pliku
- filetype -- Pobiera typ pliku
- flock -- Portable advisory file locking
- fnmatch -- Match filename against a pattern
- fopen -- Otwiera plik lub URL
- fpassthru -- Output all remaining data on a file pointer
- fputcsv -- Format line as CSV and write to file pointer
- fputs -- Alias dla fwrite()
- fread -- Odczyt pliku binarnie bezpieczy
- fscanf -- Przetwarza dane z pliku według formatu
- fseek -- Seeks on a file pointer
- fstat -- Pobiera informacje o pliku używając otwartego wskaźnika pliku
- ftell -- Mówi o pozycji odczyt/zapis wskaźnika pliku
- ftruncate -- Przycina plik do podanej długości
- fwrite -- Zapis pliku binarnie bezpieczny
- glob -- Find pathnames matching a pattern
- is_dir -- Mówi czy nazwa_pliku jest katalogiem
- is_executable -- Mówi czy plik jest wykonywalny
- is_file -- Mówi czy nazwa_pliku jest zwykłym plikiem
- is_link -- Mówi czy nazwa_pliku jest dowiązaniem symbolicznym
- is_readable -- Tells whether the filename is readable
- is_uploaded_file -- Mówi czy plik został przysłany przez HTTP POST.
- is_writable -- Tells whether the filename is writable
- is_writeable -- Alias dla is_writable()
- lchgrp -- Changes group ownership of symlink
- lchown -- Changes user ownership of symlink
- link -- Tworzy dowiÄ…zanie twarde
- linkinfo -- Pobiera informacje o linku
- lstat -- Podaje informacje o pliku lub dowiÄ…zaniu symbolicznym
- mkdir -- Tworzy katalog
- move_uploaded_file -- PrzenieÅ› uploadowany plik do innej lokalizacji
- parse_ini_file -- Parse a configuration file
- pathinfo -- Zwraca informacje o ścieżce do pliku
- pclose -- Zamyka wskaźnik pliku do procesu
- popen -- Otwiera wskaźnik pliku do procesu
- readfile -- Wyświetla plik
- readlink -- Zwraca cel linku symbolicznego
- realpath -- Returns canonicalized absolute pathname
- rename -- Renames a file or directory
- rewind -- Rewind the position of a file pointer
- rmdir -- Usuwanie katalogów
- set_file_buffer -- Alias dla stream_set_write_buffer()
- stat -- Gives information about a file
- symlink -- Tworzy dowiÄ…zanie symboliczne
- tempnam -- Create file with unique file name
- tmpfile -- Tworzy plik tymczasowy
- touch -- Ustawia czas modyfikacji pliku
- umask -- Changes the current umask
- unlink -- Kasowanie pliku