3v4l.org

run code in 300+ PHP versions simultaneously
<?php class sf extends php_user_filter { function onCreate() { //var_dump($this); } function filter($in, $out, &$consumed, $closing) { //var_dump(func_get_args()); if(!$closing) { $bucket = stream_bucket_make_writeable($in); $bucket->data = 'A'.$bucket->data.'B'; $consumed += $bucket->datalen; stream_bucket_prepend($out, $bucket); return PSFS_PASS_ON; } else { return PSFS_FEED_ME; } } } $r = fopen('php://memory', 'wb+'); stream_filter_register('sf', 'sf' ); stream_filter_append($r, 'sf', STREAM_FILTER_READ); fwrite($r, 'lol'); rewind($r); var_dump(fread($r, 1)); echo fread($r, 2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0pA5M
function name:  (null)
number of ops:  34
compiled vars:  !0 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'fopen'
          1        SEND_VAL                                                 'php%3A%2F%2Fmemory'
          2        SEND_VAL                                                 'wb%2B'
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   28     5        INIT_FCALL                                               'stream_filter_register'
          6        SEND_VAL                                                 'sf'
          7        SEND_VAL                                                 'sf'
          8        DO_ICALL                                                 
   31     9        INIT_FCALL                                               'stream_filter_append'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 'sf'
         12        SEND_VAL                                                 1
         13        DO_ICALL                                                 
   33    14        INIT_FCALL                                               'fwrite'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 'lol'
         17        DO_ICALL                                                 
   34    18        INIT_FCALL                                               'rewind'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
   35    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'fread'
         23        SEND_VAR                                                 !0
         24        SEND_VAL                                                 1
         25        DO_ICALL                                         $7      
         26        SEND_VAR                                                 $7
         27        DO_ICALL                                                 
   36    28        INIT_FCALL                                               'fread'
         29        SEND_VAR                                                 !0
         30        SEND_VAL                                                 2
         31        DO_ICALL                                         $9      
         32        ECHO                                                     $9
         33      > RETURN                                                   1

Class sf:
Function oncreate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0pA5M
function name:  onCreate
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   null

End of function oncreate

Function filter:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 23
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0pA5M
function name:  filter
number of ops:  25
compiled vars:  !0 = $in, !1 = $out, !2 = $consumed, !3 = $closing, !4 = $bucket
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   10     4        BOOL_NOT                                         ~5      !3
          5      > JMPZ                                                     ~5, ->23
   11     6    >   INIT_FCALL                                               'stream_bucket_make_writeable'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !4, $6
   12    10        FETCH_OBJ_R                                      ~9      !4, 'data'
         11        CONCAT                                           ~10     'A', ~9
         12        CONCAT                                           ~11     ~10, 'B'
         13        ASSIGN_OBJ                                               !4, 'data'
         14        OP_DATA                                                  ~11
   14    15        FETCH_OBJ_R                                      ~12     !4, 'datalen'
         16        ASSIGN_OP                                     1          !2, ~12
   15    17        INIT_FCALL                                               'stream_bucket_prepend'
         18        SEND_VAR                                                 !1
         19        SEND_VAR                                                 !4
         20        DO_ICALL                                                 
   18    21      > RETURN                                                   2
         22*       JMP                                                      ->24
   20    23    > > RETURN                                                   1
   22    24*     > RETURN                                                   null

End of function filter

End of class sf.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.26 ms | 941 KiB | 32 Q