3v4l.org

run code in 300+ PHP versions simultaneously
<?php //echo __FILE__; if (strlen(__FILE__) < 20) { $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'; return; } __halt_compiler(); //echo __FILE__; class Custom_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', 'Custom_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');
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 1, Position 2 = 20
Branch analysis from position: 1
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F8dp0
function name:  (null)
number of ops:  21
compiled vars:  !0 = $fp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > JMPZ                                                     <true>, ->20
    7     1    >   INIT_FCALL                                               'fopen'
          2        SEND_VAL                                                 '%2Fin%2FF8dp0'
          3        SEND_VAL                                                 'r'
          4        DO_ICALL                                         $1      
          5        ASSIGN                                                   !0, $1
   10     6        INIT_FCALL                                               'fseek'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 317
          9        DO_ICALL                                                 
   12    10        INIT_FCALL                                               'file_put_contents'
         11        SEND_VAL                                                 '%2Ftmp%2Fabcdefghi.php'
         12        INIT_FCALL                                               'stream_get_contents'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $4      
         15        CONCAT                                           ~5      '%3C%3Fphp%0A', $4
         16        SEND_VAL                                                 ~5
         17        DO_ICALL                                                 
   13    18        INCLUDE_OR_EVAL                                          '%2Ftmp%2Fabcdefghi.php', REQUIRE_ONCE
   14    19      > RETURN                                                   null
   17    20    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.09 ms | 1395 KiB | 21 Q