This article mainly introduces the special protocols in php, php:// protocol is explained in detail, interested friends can learn more.
php://—Access each input/output stream (I/O streams)
PHP provides some miscellaneous input/output (IO) streams, allowing access to PHP's input and output streams, standard input and output, and error descriptors, in-memory, and disk backup Temporary file streams and filters that can operate on other read and write file resources.
STDINis not affected. Note that PHP's behavior in this area was buggy until PHP 5.2.1. It is recommended that you simply use the constants
STDIN,
STDOUTand
STDERRinstead of manually opening these wrappers.
##php://output
is a write-only data stream. Allows you to
the same way asechoWrite to the output buffer.
php://fd
Allows direct access to the specified file descriptor. For example, references file descriptor 3.
php://memory and php://temp
and is a similar file A wrapper for data streams that allows reading and writing temporary data. The only difference between the two is that always stores data in memory, while will be deleted after the amount of memory reaches a predefined limit (the default is 2MB) is stored in a temporary file. The determination of the temporary file location is consistent with
.
The memory limit can be controlled by adding /maxmemory:NN. NN is the maximum amount of data retained in memory in bytes. If it exceeds, temporary files will be used.
is a meta wrapper, Designed for filtering applications when a data stream is opened. This is useful for all-in-one file functions likereadfile(),file()andfile_get_contents(), There is no opportunity to apply additional filters before the data stream content is read.
The target uses the following parameters as part of its path. Composite filter chains can be specified on a path. For detailed use of these parameters, please refer to specific examples.
Name | Description |
---|---|
resource= | This parameter is required. It specifies the data stream you want to filter. |
read=
|
This parameter is optional. You can set one or more filter names, separated by pipe characters (|). |
write=
|
This parameter is optional. You can set one or more filter names, separated by pipe characters (|). |
|
Any filter list not prefixed with read= or write= will be applied to read or write= as appropriate Write chain. |
Attributes | Supported |
---|---|
First followed by allow_url_fopen | No |
Only php://input, php://stdin, php://memory and php://temp. | |
Only php://stdin, php://input, php://fd, php://memory and php:// temp. | |
Only php://stdout, php://stderr, php://output, php://fd, php:// memory and php://temp. | |
Only php://stdout, php://stderr, php://output, php://fd, php://memory and php://temp (equal to writing) | |
Only php://fd, php://memory and php:// temp. | |
stat() | Only php://memory and php://temp.|
unlink() | No|
rename() | No|
mkdir() | No|
rmdir() | No|
stream_select() | php://stdin , php://stdout, php://stderr, php://fd and php://temp.
Version | Description |
---|---|
5.3.6 | Added. |
5.1.0 | Added and . |
5.0.0 | Added. |
##Example #1 php://temp/maxmemory
This optional option allows setting the maximum memory limit before starting to use temporary files.
##Example #2 php://filter/resource=
This parameter must be located at the end of and points to the data stream that needs to be filtered.
Example #3 php://filter/read=
This parameter takes one or multiple filter names separated by pipe characters |.
##Related recommendations:
Http protocol post request parameters in PHP, php protocol post request_PHP tutorial
Http protocol post request parameters in PHP, php protocol post request
php post submission appears Input variables exceeded 1000
The above is the detailed content of Special protocols in php, detailed explanation of php:// protocol. For more information, please follow other related articles on the PHP Chinese website!