3v4l.org

run code in 500+ PHP versions simultaneously
<?php // based on Alexandre Daubois code // Refactored to make it running here class MockHttp { private string $data = ''; private int $pos = 0; public $context; public function stream_open( string $path, string $mode, int $options, ?string &$opened_path = null ): bool { $this->data = json_encode([ 'mocked' => true, 'url' => $path, ]); $this->pos = 0; return true; } public function stream_read(int $count): string { $result = substr($this->data, $this->pos, $count); $this->pos += strlen($result); return $result; } public function stream_eof(): bool { return $this->pos >= strlen($this->data); } public function stream_stat(): array { return [ 'size' => strlen($this->data), ]; } // Required when using STREAM_IS_URL in modern PHP versions public function url_stat(string $path, int $flags): array|false { return [ 'size' => strlen($this->data), ]; } } stream_wrapper_unregister('http'); stream_wrapper_register('http', MockHttp::class, STREAM_IS_URL); $data = file_get_contents('http://api.example.com/users'); var_dump($data); stream_wrapper_restore('http');
Output for rfc.property-hooks, git.master_jit, git.master
string(55) "{"mocked":true,"url":"http:\/\/api.example.com\/users"}"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
30.99 ms | 2738 KiB | 4 Q