Context Options and Parameters Flashcards
What does stream_context_create() do?
It creates a stream context with various options.
What does stream_wrapper_register() do?
It registers a URL wrapper implemented as a PHP class. Allows you to implement your own protocol handlers and streams for use with all the other filesystem functions (such as fopen(), fread() etc.).
What does the php:// stream allow access to?
PHP’s own input and output streams, the standard input, output and error file descriptors, in-memory and disk-backed temporary file streams, and filters that can manipulate other file resources as they are read from and written to.
Can you read from php://stdout or php://stderr?
No, they are write-only.
What is php://input?
A read-only stream that allows you to read raw data from the request body. In the case of POST requests, it is preferable to use php://input instead of $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives.
What is php://output?
It’s a write-only stream that allows you to write to the output buffer mechanism in the same way as print and echo.
What is the difference between php://memory and php://temp?
php://memory will always store its data in memory, whereas php://temp will use a temporary file once the amount of data stored hits a predefined limit (the default is 2 MB).
How can you control the memory limit of php://memory?
By appending /maxmemory:NN, where NN is the maximum amount of data to keep in memory before using a temporary file, in bytes.
What is php://filter for?
It’s a kind of meta-wrapper designed to permit the application of filters to a stream at the time of opening. This is useful with all-in-one file functions such as readfile(), file(), and file_get_contents() where there is otherwise no opportunity to apply a filter to the stream prior the contents being read.
What are zlib://, bzip2://, and zip://?
Compression streams.
What is the glob:// stream?
Find pathnames matching pattern.