3v4l.org

run code in 300+ PHP versions simultaneously
<?php $protocol = 'aaa'; $registered = stream_register_wrapper($protocol, MyStreamWrapper::class); var_dump([ 'registered' => $registered, 'wrappers' => stream_get_wrappers(), 'path' => $path = "{$protocol}:/test", 'file_exists' => file_exists($path), 'is_dir' => is_dir($path), 'file_get_contents' => file_get_contents("{$path}/file.txt"), ]); class MyStreamWrapper { public $context ; public function dir_closedir() : bool { var_dump(__METHOD__, func_get_args()); } public function dir_opendir(string $path , int $options) : bool { var_dump(__METHOD__, func_get_args()); } public function dir_readdir() : string { var_dump(__METHOD__, func_get_args()); } public function dir_rewinddir() : bool { var_dump(__METHOD__, func_get_args()); } public function mkdir ( string $path , int $mode , int $options ) : bool { var_dump(__METHOD__, func_get_args()); } public function rename ( string $path_from , string $path_to ) : bool { var_dump(__METHOD__, func_get_args()); } public function rmdir ( string $path , int $options ) : bool { var_dump(__METHOD__, func_get_args()); } public function stream_cast ( int $cast_as ) { var_dump(__METHOD__, func_get_args()); } public function stream_close() : void { var_dump(__METHOD__, func_get_args()); } public function stream_eof() : bool { var_dump(__METHOD__, func_get_args()); } public function stream_flush() : bool { var_dump(__METHOD__, func_get_args()); } public function stream_lock(int $operation) : bool { var_dump(__METHOD__, func_get_args()); } public function stream_metadata(string $path , int $option , mixed $value) : bool { var_dump(__METHOD__, func_get_args()); } public function stream_open(string $path , string $mode , int $options , string &$opened_path) : bool { var_dump(__METHOD__, func_get_args()); } public function stream_read(int $count) : string { var_dump(__METHOD__, func_get_args()); } public function stream_seek(int $offset , int $whence = SEEK_SET) : bool { var_dump(__METHOD__, func_get_args()); } public function stream_set_option(int $option , int $arg1 , int $arg2) : bool { var_dump(__METHOD__, func_get_args()); } public function stream_stat() : array { var_dump(__METHOD__, func_get_args()); } public function stream_tell() : int { var_dump(__METHOD__, func_get_args()); } public function stream_truncate(int $new_size) : bool { var_dump(__METHOD__, func_get_args()); } public function stream_write(string $data) : int { var_dump(__METHOD__, func_get_args()); } public function unlink(string $path) : bool { var_dump(__METHOD__, func_get_args()); } public function url_stat(string $path , int $flags) : array { var_dump(__METHOD__, func_get_args()); } }
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Warning: file_exists(): open_basedir restriction in effect. File(aaa:/test) is not within the allowed path(s): (/tmp:/in:/etc) in /in/ISuCn on line 9 Warning: is_dir(): open_basedir restriction in effect. File(aaa:/test) is not within the allowed path(s): (/tmp:/in:/etc) in /in/ISuCn on line 10 Warning: file_get_contents(): open_basedir restriction in effect. File(aaa:/test/file.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/ISuCn on line 11 Warning: file_get_contents(aaa:/test/file.txt): Failed to open stream: Operation not permitted in /in/ISuCn on line 11 array(6) { ["registered"]=> bool(true) ["wrappers"]=> array(9) { [0]=> string(13) "compress.zlib" [1]=> string(3) "php" [2]=> string(4) "file" [3]=> string(4) "glob" [4]=> string(4) "data" [5]=> string(4) "http" [6]=> string(3) "ftp" [7]=> string(4) "phar" [8]=> string(3) "aaa" } ["path"]=> string(9) "aaa:/test" ["file_exists"]=> bool(false) ["is_dir"]=> bool(false) ["file_get_contents"]=> bool(false) }
Output for 8.0.13
Warning: file_get_contents(aaa:/test/file.txt): Failed to open stream: No such file or directory in /in/ISuCn on line 11 array(6) { ["registered"]=> bool(true) ["wrappers"]=> array(9) { [0]=> string(13) "compress.zlib" [1]=> string(3) "php" [2]=> string(4) "file" [3]=> string(4) "glob" [4]=> string(4) "data" [5]=> string(4) "http" [6]=> string(3) "ftp" [7]=> string(4) "phar" [8]=> string(3) "aaa" } ["path"]=> string(9) "aaa:/test" ["file_exists"]=> bool(false) ["is_dir"]=> bool(false) ["file_get_contents"]=> bool(false) }
Output for 7.3.32 - 7.3.33, 7.4.33
Warning: file_get_contents(aaa:/test/file.txt): failed to open stream: No such file or directory in /in/ISuCn on line 11 array(6) { ["registered"]=> bool(true) ["wrappers"]=> array(9) { [0]=> string(13) "compress.zlib" [1]=> string(3) "php" [2]=> string(4) "file" [3]=> string(4) "glob" [4]=> string(4) "data" [5]=> string(4) "http" [6]=> string(3) "ftp" [7]=> string(4) "phar" [8]=> string(3) "aaa" } ["path"]=> string(9) "aaa:/test" ["file_exists"]=> bool(false) ["is_dir"]=> bool(false) ["file_get_contents"]=> bool(false) }
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.32
Warning: file_exists(): open_basedir restriction in effect. File(aaa:/test) is not within the allowed path(s): (/tmp:/in:/etc) in /in/ISuCn on line 9 Warning: is_dir(): open_basedir restriction in effect. File(aaa:/test) is not within the allowed path(s): (/tmp:/in:/etc) in /in/ISuCn on line 10 Warning: file_get_contents(): open_basedir restriction in effect. File(aaa:/test/file.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/ISuCn on line 11 Warning: file_get_contents(aaa:/test/file.txt): failed to open stream: Operation not permitted in /in/ISuCn on line 11 array(6) { ["registered"]=> bool(true) ["wrappers"]=> array(9) { [0]=> string(13) "compress.zlib" [1]=> string(3) "php" [2]=> string(4) "file" [3]=> string(4) "glob" [4]=> string(4) "data" [5]=> string(4) "http" [6]=> string(3) "ftp" [7]=> string(4) "phar" [8]=> string(3) "aaa" } ["path"]=> string(9) "aaa:/test" ["file_exists"]=> bool(false) ["is_dir"]=> bool(false) ["file_get_contents"]=> bool(false) }
Output for 7.1.20, 7.2.6
Warning: file_exists(): open_basedir restriction in effect. File(aaa:/test) is not within the allowed path(s): (/tmp:/in) in /in/ISuCn on line 9 Warning: is_dir(): open_basedir restriction in effect. File(aaa:/test) is not within the allowed path(s): (/tmp:/in) in /in/ISuCn on line 10 Warning: file_get_contents(): open_basedir restriction in effect. File(aaa:/test/file.txt) is not within the allowed path(s): (/tmp:/in) in /in/ISuCn on line 11 Warning: file_get_contents(aaa:/test/file.txt): failed to open stream: Operation not permitted in /in/ISuCn on line 11 array(6) { ["registered"]=> bool(true) ["wrappers"]=> array(9) { [0]=> string(13) "compress.zlib" [1]=> string(3) "php" [2]=> string(4) "file" [3]=> string(4) "glob" [4]=> string(4) "data" [5]=> string(4) "http" [6]=> string(3) "ftp" [7]=> string(4) "phar" [8]=> string(3) "aaa" } ["path"]=> string(9) "aaa:/test" ["file_exists"]=> bool(false) ["is_dir"]=> bool(false) ["file_get_contents"]=> bool(false) }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0
Warning: file_get_contents(aaa:/test/file.txt): failed to open stream: No such file or directory in /in/ISuCn on line 11 array(6) { ["registered"]=> bool(true) ["wrappers"]=> array(11) { [0]=> string(5) "https" [1]=> string(4) "ftps" [2]=> string(13) "compress.zlib" [3]=> string(3) "php" [4]=> string(4) "file" [5]=> string(4) "glob" [6]=> string(4) "data" [7]=> string(4) "http" [8]=> string(3) "ftp" [9]=> string(4) "phar" [10]=> string(3) "aaa" } ["path"]=> string(9) "aaa:/test" ["file_exists"]=> bool(false) ["is_dir"]=> bool(false) ["file_get_contents"]=> bool(false) }
Output for 5.6.0 - 5.6.29
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/ISuCn on line 17
Process exited with code 255.

preferences:
131.63 ms | 401 KiB | 196 Q