Skip to content

Instantly share code, notes, and snippets.

@mikey179
Created April 19, 2016 13:35
Show Gist options
  • Save mikey179/f904f99a261a013c3155e8ef350d1af6 to your computer and use it in GitHub Desktop.
Save mikey179/f904f99a261a013c3155e8ef350d1af6 to your computer and use it in GitHub Desktop.
<?php
class MyStreamWrapper {
private $read = false;
public function stream_open($path , $mode , $options , &$opened_path) {
return true;
}
public function stream_stat() {
return [];
}
public function stream_read($count) {
if (!$this->read) {
$this->read = true;
return 'Hello world!';
}
return false;
}
public function stream_eof() {
return $this->read;
}
}
stream_wrapper_register('my', MyStreamWrapper::class);
var_dump(file_get_contents('my://hello'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment