1 file_example_session_streams.inc public FileExampleSessionStreamWrapper::stream_write($data)

Support for fwrite(), file_put_contents() etc.

Parameters

string $data: The string to be written.

Return value

int: The number of bytes written (integer).

Overrides StreamWrapperInterface::stream_write

See also

http://php.net/manual/en/streamwrapper.stream-write.php

File

modules/examples/file_example/file_example_session_streams.inc, line 342
Provides a demonstration session:// stream-wrapper.

Class

FileExampleSessionStreamWrapper
Example stream wrapper class to handle session:// streams.

Code

public function stream_write($data) {
  // Sanitize the data in a simple way since we're putting it into the
  // session variable.
  $data = check_plain($data);
  $this->sessionContent = substr_replace($this->sessionContent, $data, $this->streamPointer);
  $this->streamPointer += backdrop_strlen($data);

  return backdrop_strlen($data);
}