- stream_wrapper_register: documentation ( source)
- fread: documentation ( source)
- fopen: documentation ( source)
<?php
class MyStream
{
public function stream_open() { return true; }
public function stream_read()
{
throw new Exception('boo!');
return 42;
}
public function stream_eof()
{
return true;
}
}
try
{
stream_wrapper_register("my", "MyStream");
$fp = fopen('my://foobar', 'r+');
fread($fp, 512);
}
catch (Exception $e)
{
echo 'e';
}