Context Options and Parameters Flashcards

1
Q

What does stream_context_create() do?

A

It creates a stream context with various options.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does stream_wrapper_register() do?

A

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.).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the php:// stream allow access to?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can you read from php://stdout or php://stderr?

A

No, they are write-only.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is php://input?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is php://output?

A

It’s a write-only stream that allows you to write to the output buffer mechanism in the same way as print and echo.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between php://memory and php://temp?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can you control the memory limit of php://memory?

A

By appending /maxmemory:NN, where NN is the maximum amount of data to keep in memory before using a temporary file, in bytes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is php://filter for?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are zlib://, bzip2://, and zip://?

A

Compression streams.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the glob:// stream?

A

Find pathnames matching pattern.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly