3v4l.org

run code in 300+ PHP versions simultaneously
<?php class VariableStream { var $position; var $varname; function stream_open($path, $mode, $options, &$opened_path) { $url = parse_url($path); $this->varname = $url["host"]; $this->position = 0; return true; } function stream_read($count) { $p=&$this->position; $ret = substr($GLOBALS[$this->varname], $p, $count); $p += strlen($ret); return $ret; } function stream_write($data){ $v=&$GLOBALS[$this->varname]; $l=strlen($data); $p=&$this->position; $v = substr($v, 0, $p) . $data . substr($v, $p += $l); return $l; } function stream_stat(){ $v=&$GLOBALS[$this->varname]; return array( -1, /*dev*/ 0, /*ino*/ 0, /*mode*/ 1, /*nlink*/ 0, /*uid*/ 0, /*gid*/ 0, /*rdev*/ strlen($v), /*size*/ 0, /*atime*/ 0, /*mtime*/ 0, /*ctime*/ -1, /*blksize*/ -1, /*blocks*/); } function stream_tell() { return $this->position; } function stream_eof() { return $this->position >= strlen($GLOBALS[$this->varname]); } function stream_seek($offset, $whence) { $l=strlen($GLOBALS[$this->varname]); $p=&$this->position; switch ($whence) { case SEEK_SET: $newPos = $offset; break; case SEEK_CUR: $newPos = $p + $offset; break; case SEEK_END: $newPos = $l + $offset; break; default: return false; } $ret = ($newPos >=0 && $newPos <=$l); if ($ret) $p=$newPos; return $ret; } } stream_wrapper_register("var", "VariableStream") or die("Failed to register protocol"); function test_parse($lang) { global $inivar; $inivar = 'standard_lang='.$lang; $arr = parse_ini_file('var://inivar'); var_dump($arr['standard_lang']); } test_parse('en'); test_parse('de'); test_parse('no'); test_parse('es'); test_parse('yes');
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YJRCT
function name:  (null)
number of ops:  23
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   INIT_FCALL                                               'stream_wrapper_register'
          1        SEND_VAL                                                 'var'
          2        SEND_VAL                                                 'VariableStream'
          3        DO_ICALL                                         $0      
          4      > JMPNZ_EX                                         ~1      $0, ->7
   63     5    > > EXIT                                                     'Failed+to+register+protocol'
          6*       BOOL                                             ~1      <true>
   73     7    >   INIT_FCALL                                               'test_parse'
          8        SEND_VAL                                                 'en'
          9        DO_FCALL                                      0          
   74    10        INIT_FCALL                                               'test_parse'
         11        SEND_VAL                                                 'de'
         12        DO_FCALL                                      0          
   75    13        INIT_FCALL                                               'test_parse'
         14        SEND_VAL                                                 'no'
         15        DO_FCALL                                      0          
   76    16        INIT_FCALL                                               'test_parse'
         17        SEND_VAL                                                 'es'
         18        DO_FCALL                                      0          
   77    19        INIT_FCALL                                               'test_parse'
         20        SEND_VAL                                                 'yes'
         21        DO_FCALL                                      0          
         22      > RETURN                                                   1

Function test_parse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YJRCT
function name:  test_parse
number of ops:  13
compiled vars:  !0 = $lang, !1 = $inivar, !2 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     0  E >   RECV                                             !0      
   67     1        BIND_GLOBAL                                              !1, 'inivar'
   68     2        CONCAT                                           ~3      'standard_lang%3D', !0
          3        ASSIGN                                                   !1, ~3
   69     4        INIT_FCALL                                               'parse_ini_file'
          5        SEND_VAL                                                 'var%3A%2F%2Finivar'
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !2, $5
   70     8        INIT_FCALL                                               'var_dump'
          9        FETCH_DIM_R                                      ~7      !2, 'standard_lang'
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                                 
   71    12      > RETURN                                                   null

End of function test_parse

Class VariableStream:
Function stream_open:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YJRCT
function name:  stream_open
number of ops:  15
compiled vars:  !0 = $path, !1 = $mode, !2 = $options, !3 = $opened_path, !4 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    7     4        INIT_FCALL                                               'parse_url'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !4, $5
    8     8        FETCH_DIM_R                                      ~8      !4, 'host'
          9        ASSIGN_OBJ                                               'varname'
         10        OP_DATA                                                  ~8
    9    11        ASSIGN_OBJ                                               'position'
         12        OP_DATA                                                  0
   10    13      > RETURN                                                   <true>
   11    14*     > RETURN                                                   null

End of function stream_open

Function stream_read:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YJRCT
function name:  stream_read
number of ops:  15
compiled vars:  !0 = $count, !1 = $p, !2 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        FETCH_OBJ_W                                      $3      'position'
          2        ASSIGN_REF                                               !1, $3
   14     3        INIT_FCALL                                               'substr'
          4        FETCH_OBJ_R                                      ~5      'varname'
          5        FETCH_R                      global              ~6      ~5
          6        SEND_VAL                                                 ~6
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !2, $7
   15    11        STRLEN                                           ~9      !2
         12        ASSIGN_OP                                     1          !1, ~9
   16    13      > RETURN                                                   !2
   17    14*     > RETURN                                                   null

End of function stream_read

Function stream_write:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YJRCT
function name:  stream_write
number of ops:  23
compiled vars:  !0 = $data, !1 = $v, !2 = $l, !3 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        FETCH_OBJ_R                                      ~4      'varname'
          2        FETCH_W                      global              $5      ~4
          3        ASSIGN_REF                                               !1, $5
   20     4        STRLEN                                           ~7      !0
          5        ASSIGN                                                   !2, ~7
   21     6        FETCH_OBJ_W                                      $9      'position'
          7        ASSIGN_REF                                               !3, $9
   22     8        INIT_FCALL                                               'substr'
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 0
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $11     
         13        CONCAT                                           ~12     $11, !0
         14        INIT_FCALL                                               'substr'
         15        SEND_VAR                                                 !1
         16        ASSIGN_OP                                     1  ~13     !3, !2
         17        SEND_VAL                                                 ~13
         18        DO_ICALL                                         $14     
         19        CONCAT                                           ~15     ~12, $14
         20        ASSIGN                                                   !1, ~15
   23    21      > RETURN                                                   !2
   24    22*     > RETURN                                                   null

End of function stream_write

Function stream_stat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YJRCT
function name:  stream_stat
number of ops:  19
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   FETCH_OBJ_R                                      ~1      'varname'
          1        FETCH_W                      global              $2      ~1
          2        ASSIGN_REF                                               !0, $2
   28     3        INIT_ARRAY                                       ~4      -1
   29     4        ADD_ARRAY_ELEMENT                                ~4      0
   30     5        ADD_ARRAY_ELEMENT                                ~4      0
   31     6        ADD_ARRAY_ELEMENT                                ~4      1
   32     7        ADD_ARRAY_ELEMENT                                ~4      0
   33     8        ADD_ARRAY_ELEMENT                                ~4      0
   34     9        ADD_ARRAY_ELEMENT                                ~4      0
   35    10        STRLEN                                           ~5      !0
         11        ADD_ARRAY_ELEMENT                                ~4      ~5
   36    12        ADD_ARRAY_ELEMENT                                ~4      0
   37    13        ADD_ARRAY_ELEMENT                                ~4      0
   38    14        ADD_ARRAY_ELEMENT                                ~4      0
   28    15        ADD_ARRAY_ELEMENT                                ~4      -1
         16        ADD_ARRAY_ELEMENT                                ~4      -1
         17      > RETURN                                                   ~4
   41    18*     > RETURN                                                   null

End of function stream_stat

Function stream_tell:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YJRCT
function name:  stream_tell
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   FETCH_OBJ_R                                      ~0      'position'
          1      > RETURN                                                   ~0
   44     2*     > RETURN                                                   null

End of function stream_tell

Function stream_eof:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YJRCT
function name:  stream_eof
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   FETCH_OBJ_R                                      ~0      'position'
          1        FETCH_OBJ_R                                      ~1      'varname'
          2        FETCH_R                      global              ~2      ~1
          3        STRLEN                                           ~3      ~2
          4        IS_SMALLER_OR_EQUAL                              ~4      ~3, ~0
          5      > RETURN                                                   ~4
   47     6*     > RETURN                                                   null

End of function stream_eof

Function stream_seek:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 31
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 28
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
filename:       /in/YJRCT
function name:  stream_seek
number of ops:  33
compiled vars:  !0 = $offset, !1 = $whence, !2 = $l, !3 = $p, !4 = $newPos, !5 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   49     2        FETCH_OBJ_R                                      ~6      'varname'
          3        FETCH_R                      global              ~7      ~6
          4        STRLEN                                           ~8      ~7
          5        ASSIGN                                                   !2, ~8
   50     6        FETCH_OBJ_W                                      $10     'position'
          7        ASSIGN_REF                                               !3, $10
   51     8        IS_EQUAL                                                 !1, 0
          9      > JMPNZ                                                    ~12, ->15
         10    >   IS_EQUAL                                                 !1, 1
         11      > JMPNZ                                                    ~12, ->17
         12    >   IS_EQUAL                                                 !1, 2
         13      > JMPNZ                                                    ~12, ->20
         14    > > JMP                                                      ->23
   52    15    >   ASSIGN                                                   !4, !0
         16      > JMP                                                      ->24
   53    17    >   ADD                                              ~14     !3, !0
         18        ASSIGN                                                   !4, ~14
         19      > JMP                                                      ->24
   54    20    >   ADD                                              ~16     !2, !0
         21        ASSIGN                                                   !4, ~16
         22      > JMP                                                      ->24
   55    23    > > RETURN                                                   <false>
   57    24    >   IS_SMALLER_OR_EQUAL                              ~18     0, !4
         25      > JMPZ_EX                                          ~18     ~18, ->28
         26    >   IS_SMALLER_OR_EQUAL                              ~19     !4, !2
         27        BOOL                                             ~18     ~19
         28    >   ASSIGN                                                   !5, ~18
   58    29      > JMPZ                                                     !5, ->31
         30    >   ASSIGN                                                   !3, !4
   59    31    > > RETURN                                                   !5
   60    32*     > RETURN                                                   null

End of function stream_seek

End of class VariableStream.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.2 ms | 1037 KiB | 23 Q