3v4l.org

run code in 300+ PHP versions simultaneously
<?php fclose(STDOUT); $STDOUT = fopen('php://output', 'wt'); class TestFilterClass { function filter($in, $out) { while (true) { $bucket = stream_bucket_make_writeable($in); if (is_object($bucket)) { $bucket->data = sprintf('[%s] %s', __METHOD__, $bucket->data); stream_bucket_append($out, $bucket); } break; } return PSFS_PASS_ON; } } if (stream_filter_register('TestFilter', 'TestFilterClass')) { $handle = stream_filter_append($STDOUT, 'TestFilter'); if (is_resource($handle)) { fwrite($STDOUT, 'hello world' . PHP_EOL); // ok echo 'hello world' . PHP_EOL; // nope stream_filter_remove($handle); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 29
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 29
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 29
filename:       /in/oks59
function name:  (null)
number of ops:  30
compiled vars:  !0 = $STDOUT, !1 = $handle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'fclose'
          1        FETCH_CONSTANT                                   ~2      'STDOUT'
          2        SEND_VAL                                                 ~2
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'fopen'
          5        SEND_VAL                                                 'php%3A%2F%2Foutput'
          6        SEND_VAL                                                 'wt'
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !0, $4
   26     9        INIT_FCALL                                               'stream_filter_register'
         10        SEND_VAL                                                 'TestFilter'
         11        SEND_VAL                                                 'TestFilterClass'
         12        DO_ICALL                                         $6      
         13      > JMPZ                                                     $6, ->29
   28    14    >   INIT_FCALL                                               'stream_filter_append'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 'TestFilter'
         17        DO_ICALL                                         $7      
         18        ASSIGN                                                   !1, $7
   29    19        TYPE_CHECK                                  512          !1
         20      > JMPZ                                                     ~9, ->29
   31    21    >   INIT_FCALL                                               'fwrite'
         22        SEND_VAR                                                 !0
         23        SEND_VAL                                                 'hello+world%0A'
         24        DO_ICALL                                                 
   32    25        ECHO                                                     'hello+world%0A'
   34    26        INIT_FCALL                                               'stream_filter_remove'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                                 
   36    29    > > RETURN                                                   1

Class TestFilterClass:
Function filter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 3
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 21
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 21
filename:       /in/oks59
function name:  filter
number of ops:  25
compiled vars:  !0 = $in, !1 = $out, !2 = $bucket
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2      > JMP                                                      ->22
   13     3    >   INIT_FCALL                                               'stream_bucket_make_writeable'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !2, $3
   14     7        TYPE_CHECK                                  256          !2
          8      > JMPZ                                                     ~5, ->21
   16     9    >   INIT_FCALL                                               'sprintf'
         10        SEND_VAL                                                 '%5B%25s%5D+%25s'
         11        SEND_VAL                                                 'TestFilterClass%3A%3Afilter'
         12        FETCH_OBJ_R                                      ~7      !2, 'data'
         13        SEND_VAL                                                 ~7
         14        DO_ICALL                                         $8      
         15        ASSIGN_OBJ                                               !2, 'data'
         16        OP_DATA                                                  $8
   17    17        INIT_FCALL                                               'stream_bucket_append'
         18        SEND_VAR                                                 !1
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
   19    21    > > JMP                                                      ->23
   11    22    > > JMPNZ                                                    <true>, ->3
   21    23    > > RETURN                                                   2
   22    24*     > RETURN                                                   null

End of function filter

End of class TestFilterClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.13 ms | 1392 KiB | 31 Q