3v4l.org

run code in 500+ PHP versions simultaneously
<?php echo 'bug'; // Should be transformed by filter on second include if (!class_exists(SampleFilter::class)) { class SampleFilter extends php_user_filter { private $data = ''; public function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $this->data .= $bucket->data; } if ($closing || feof($this->stream)) { $consumed = strlen($this->data); $this->data = str_replace('bug', 'feature', $this->data); $bucket = stream_bucket_new($this->stream, $this->data); stream_bucket_append($out, $bucket); return PSFS_PASS_ON; } return PSFS_FEED_ME; } } stream_filter_register('sample.filter', SampleFilter::class); $uri = 'php://filter/read=sample.filter/resource='. __FILE__; $content = file_get_contents($uri); echo '<pre>', htmlentities($content), '</pre>'; // Looks good include $uri; // We expect one more "feature" output at line 3 }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/jEMEE
function name:  (null)
number of ops:  22
compiled vars:  !0 = $uri, !1 = $content
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ECHO                                                         'bug'
    5     1        FRAMELESS_ICALL_1                class_exists        ~2      'SampleFilter'
          2        BOOL_NOT                                             ~3      ~2
          3      > JMPZ                                                         ~3, ->21
    6     4    >   DECLARE_CLASS                                                'samplefilter', 'php_user_filter'
   32     5        INIT_FCALL                                                   'stream_filter_register'
          6        SEND_VAL                                                     'sample.filter'
          7        SEND_VAL                                                     'SampleFilter'
          8        DO_ICALL                                                     
   33     9        ASSIGN                                                       !0, 'php%3A%2F%2Ffilter%2Fread%3Dsample.filter%2Fresource%3D%2Fin%2FjEMEE'
   35    10        INIT_FCALL                                                   'file_get_contents'
         11        SEND_VAR                                                     !0
         12        DO_ICALL                                             $6      
         13        ASSIGN                                                       !1, $6
   36    14        ECHO                                                         '%3Cpre%3E'
         15        INIT_FCALL                                                   'htmlentities'
         16        SEND_VAR                                                     !1
         17        DO_ICALL                                             $8      
         18        ECHO                                                         $8
         19        ECHO                                                         '%3C%2Fpre%3E'
   38    20        INCLUDE_OR_EVAL                                              !0, INCLUDE
   39    21    > > RETURN                                                       1

Class SampleFilter:
Function filter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 5
Branch analysis from position: 13
2 jumps found. (Code = 47) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 40
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 5
Branch analysis from position: 13
Branch analysis from position: 5
filename:       /in/jEMEE
function name:  filter
number of ops:  42
compiled vars:  !0 = $in, !1 = $out, !2 = $consumed, !3 = $closing, !4 = $bucket
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
          3        RECV                                                 !3      
   12     4      > JMP                                                          ->8
   14     5    >   FETCH_OBJ_R                                          ~6      !4, 'data'
          6        ASSIGN_OBJ_OP                                     8          'data'
          7        OP_DATA                                                      ~6
   12     8    >   INIT_FCALL                                                   'stream_bucket_make_writeable'
          9        SEND_VAR                                                     !0
         10        DO_ICALL                                             $7      
         11        ASSIGN                                               ~8      !4, $7
         12      > JMPNZ                                                        ~8, ->5
   17    13    > > JMPNZ_EX                                             ~9      !3, ->19
         14    >   INIT_FCALL                                                   'feof'
         15        FETCH_OBJ_R                                          ~10     'stream'
         16        SEND_VAL                                                     ~10
         17        DO_ICALL                                             $11     
         18        BOOL                                                 ~9      $11
         19    > > JMPZ                                                         ~9, ->40
   19    20    >   FETCH_OBJ_R                                          ~12     'data'
         21        STRLEN                                               ~13     ~12
         22        ASSIGN                                                       !2, ~13
   21    23        FETCH_OBJ_R                                          ~16     'data'
         24        FRAMELESS_ICALL_3                str_replace         ~17     'bug', 'feature'
         25        OP_DATA                                                      ~16
         26        ASSIGN_OBJ                                                   'data'
         27        OP_DATA                                                      ~17
   23    28        INIT_FCALL                                                   'stream_bucket_new'
         29        FETCH_OBJ_R                                          ~18     'stream'
         30        SEND_VAL                                                     ~18
         31        FETCH_OBJ_R                                          ~19     'data'
         32        SEND_VAL                                                     ~19
         33        DO_ICALL                                             $20     
         34        ASSIGN                                                       !4, $20
   24    35        INIT_FCALL                                                   'stream_bucket_append'
         36        SEND_VAR                                                     !1
         37        SEND_VAR                                                     !4
         38        DO_ICALL                                                     
   26    39      > RETURN                                                       2
   29    40    > > RETURN                                                       1
   30    41*     > RETURN                                                       null

End of function filter

End of class SampleFilter.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174.45 ms | 2610 KiB | 20 Q