3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fp = fopen(__FILE__, 'r'); // seek file pointer to data fseek($fp, __COMPILER_HALT_OFFSET__); file_put_contents('/tmp/abcdefghi.php', '<?php' . PHP_EOL . stream_get_contents($fp)); require_once '/tmp/abcdefghi.php'; __halt_compiler(); class React_Loader_StreamWrapper { public $context; public static function getPath($url, $mustExist = true) { $parts = explode('://', $url, 2); list($scheme, $path) = $parts; $path = stream_resolve_include_path($path); if (false === $path) { if ($mustExist) { throw new Exception('error'); } // centralize the stream_resolve_include_path logic return self::getPath(dirname($url)) .'/'. basename($url); } return $path; } public function stream_open($path, $mode, $options, &$openedPath) { // Modes 'a', 'c', 'w', 'x' are documented as: "If the file does not exist, attempt to create it" - so detect dir first and add filename if (in_array(substr($mode, 0, 1), array('a', 'c', 'w', 'x'))) $filepath = self::getPath($path, false); if (!isset($filepath)) $filepath = self::getPath($path); if ($options & STREAM_USE_PATH) $openedPath = $filepath; $this->_fp = fopen($filepath, $mode); return (bool)$this->_fp; } public function stream_write($data) { return fwrite($this->_fp, $data); } public function unlink($path) { return unlink(self::getPath($path)); } public function url_stat($path, $flags) { try { if ($flags & STREAM_URL_STAT_LINK) return lstat(self::getPath($path)); else return stat(self::getPath($path)); } catch (Exception $e) { if ($flags & STREAM_URL_STAT_QUIET) return false; throw $e; } } } if (!is_dir('/tmp/cache')) mkdir('/tmp/cache'); set_include_path('/tmp'); stream_wrapper_register('react', 'React_Loader_StreamWrapper'); file_exists('react://cache/react_unittest_filecache'); file_put_contents('react://cache/react_unittest_filecache', 'waa'); echo 'unlink'; unlink('react://cache/react_unittest_filecache'); file_exists('react://cache/react_unittest_filecache');
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: Creation of dynamic property React_Loader_StreamWrapper::$_fp is deprecated in /tmp/abcdefghi.php on line 42 unlink
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Deprecated: Creation of dynamic property React_Loader_StreamWrapper::$_fp is deprecated in /tmp/abcdefghi.php on line 42 unlink
Output for 5.3.2 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27
unlink
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.1
Fatal error: Call to undefined function stream_resolve_include_path() in /tmp/abcdefghi.php on line 14
Process exited with code 255.
Output for 5.0.2 - 5.0.5
Notice: Use of undefined constant __COMPILER_HALT_OFFSET__ - assumed '__COMPILER_HALT_OFFSET__' in /in/iiSSb on line 6 Parse error: parse error, unexpected '<' in /tmp/abcdefghi.php on line 2
Process exited with code 255.
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant __COMPILER_HALT_OFFSET__ - assumed '__COMPILER_HALT_OFFSET__' in /in/iiSSb on line 6 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/iiSSb on line 8 <?phpPHP_EOL Notice: Use of undefined constant __COMPILER_HALT_OFFSET__ - assumed '__COMPILER_HALT_OFFSET__' in /tmp/abcdefghi.php on line 6 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /tmp/abcdefghi.php on line 8 Fatal error: Call to undefined function __halt_compiler() in /tmp/abcdefghi.php on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/iiSSb on line 15
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/iiSSb on line 15
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/iiSSb on line 15
Process exited with code 255.

preferences:
254.89 ms | 401 KiB | 467 Q