3v4l.org

run code in 300+ PHP versions simultaneously
<?php fclose(STDIN); fclose(STDOUT); fclose(STDERR); $STDIN = fopen('/dev/null', 'r'); $STDOUT = fopen('php://output', 'wb'); $STDERR = fopen('/dev/null', 'wb'); 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 = 32, Position 2 = 49
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 49
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
Branch analysis from position: 49
filename:       /in/cJBA2
function name:  (null)
number of ops:  50
compiled vars:  !0 = $STDIN, !1 = $STDOUT, !2 = $STDERR, !3 = $handle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'fclose'
          1        FETCH_CONSTANT                                   ~4      'STDIN'
          2        SEND_VAL                                                 ~4
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'fclose'
          5        FETCH_CONSTANT                                   ~6      'STDOUT'
          6        SEND_VAL                                                 ~6
          7        DO_ICALL                                                 
    5     8        INIT_FCALL                                               'fclose'
          9        FETCH_CONSTANT                                   ~8      'STDERR'
         10        SEND_VAL                                                 ~8
         11        DO_ICALL                                                 
    6    12        INIT_FCALL                                               'fopen'
         13        SEND_VAL                                                 '%2Fdev%2Fnull'
         14        SEND_VAL                                                 'r'
         15        DO_ICALL                                         $10     
         16        ASSIGN                                                   !0, $10
    7    17        INIT_FCALL                                               'fopen'
         18        SEND_VAL                                                 'php%3A%2F%2Foutput'
         19        SEND_VAL                                                 'wb'
         20        DO_ICALL                                         $12     
         21        ASSIGN                                                   !1, $12
    8    22        INIT_FCALL                                               'fopen'
         23        SEND_VAL                                                 '%2Fdev%2Fnull'
         24        SEND_VAL                                                 'wb'
         25        DO_ICALL                                         $14     
         26        ASSIGN                                                   !2, $14
   30    27        INIT_FCALL                                               'stream_filter_register'
         28        SEND_VAL                                                 'TestFilter'
         29        SEND_VAL                                                 'TestFilterClass'
         30        DO_ICALL                                         $16     
         31      > JMPZ                                                     $16, ->49
   32    32    >   INIT_FCALL                                               'stream_filter_append'
         33        FETCH_CONSTANT                                   ~17     'STDOUT'
         34        SEND_VAL                                                 ~17
         35        SEND_VAL                                                 'TestFilter'
         36        DO_ICALL                                         $18     
         37        ASSIGN                                                   !3, $18
   33    38        TYPE_CHECK                                  512          !3
         39      > JMPZ                                                     ~20, ->49
   35    40    >   INIT_FCALL                                               'fwrite'
         41        FETCH_CONSTANT                                   ~21     'STDOUT'
         42        SEND_VAL                                                 ~21
         43        SEND_VAL                                                 'hello+world%0A'
         44        DO_ICALL                                                 
   36    45        ECHO                                                     'hello+world%0A'
   38    46        INIT_FCALL                                               'stream_filter_remove'
         47        SEND_VAR                                                 !3
         48        DO_ICALL                                                 
   40    49    > > 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/cJBA2
function name:  filter
number of ops:  25
compiled vars:  !0 = $in, !1 = $out, !2 = $bucket
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2      > JMP                                                      ->22
   17     3    >   INIT_FCALL                                               'stream_bucket_make_writeable'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !2, $3
   18     7        TYPE_CHECK                                  256          !2
          8      > JMPZ                                                     ~5, ->21
   20     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
   21    17        INIT_FCALL                                               'stream_bucket_append'
         18        SEND_VAR                                                 !1
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
   23    21    > > JMP                                                      ->23
   15    22    > > JMPNZ                                                    <true>, ->3
   25    23    > > RETURN                                                   2
   26    24*     > RETURN                                                   null

End of function filter

End of class TestFilterClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.57 ms | 1400 KiB | 31 Q