5 quizzes found.

Which of the following are not true about streams?

  1. They are always seekable
  2. When used properly they significantly reduce memory consumption
  3. They can be applied to any data source
  4. They are always bi-directional
  5. They can be filtered

Choose 2 answers

Using flock() to lock a stream is only assured to work under what circumstances?

  1. When running in a Linux environment local filesystem
  2. When accessing the stream of the local filesystem
  3. When running in a Windows environment and accessing a share
  4. When accessing a bi-directional stream
  5. When accessing a read-only stream

Choose 1 answers

What is wrong with the following code snippet? Assume default configuration values apply.


$fp = fsockopen('www.php.net', 80);
fwrite($fp, "GET / HTTP/1.0\r\nHost: www.php.net\r\n");
$data = fread($fp, 8192);

  1. The request is blocking and may cause fread() to hang
  2. The HTTP request is malformed
  3. This script should be re-written using fgets() instead of fread()
  4. The request is non-blocking and fread() may miss the response
  5. You cannot use fwrite() with fsockopen()

Choose 1 answers

Example of a correct request:

POST /test/index.php HTTP/1.1
Host: mywebsite.com

_______ can be used to add additional functionality to a stream, such as implementation of a specific protocol on top of a normal PHP stream implementation.

  1. Buffered
  2. Buckets
  3. Wrappers
  4. Filters

Choose 1 answers

http://php.net/manual/en/intro.stream.php: A wrapper is additional code which tells the stream how to handle specific protocols/encodings

Which of the following functions is used to determine if a given stream is blocking or not?

  1. stream_get_blocking
  2. stream_get_meta_data
  3. stream_is_blocking
  4. stream_get_blocking_mode

Choose 1 answers