Skip to content

Instantly share code, notes, and snippets.

@jakubkulhan
Created July 29, 2010 11:42
Show Gist options
  • Save jakubkulhan/497904 to your computer and use it in GitHub Desktop.
Save jakubkulhan/497904 to your computer and use it in GitHub Desktop.
<?php
class foo
{
function stream_open() { return TRUE; }
function stream_eof() { return FALSE; }
function stream_read($count)
{
$backtrace = debug_backtrace();
if (isset($backtrace[1]['function']) && $backtrace[1]['function'] === 'fread') {
$count = $backtrace[1]['args'][1];
}
var_dump($count);
return "";
}
}
stream_wrapper_register('foo', 'foo');
$handle = fopen('foo://bar', NULL);
fread($handle, 1); // int(1)
fread($handle, 16384); // int(16384)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment