3v4l.org

run code in 300+ 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 = 6, Position 2 = 23
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/jEMEE
function name:  (null)
number of ops:  24
compiled vars:  !0 = $uri, !1 = $content
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ECHO                                                     'bug'
    5     1        INIT_FCALL                                               'class_exists'
          2        SEND_VAL                                                 'SampleFilter'
          3        DO_ICALL                                         $2      
          4        BOOL_NOT                                         ~3      $2
          5      > JMPZ                                                     ~3, ->23
    6     6    >   DECLARE_CLASS                                            'samplefilter', 'php_user_filter'
   32     7        INIT_FCALL                                               'stream_filter_register'
          8        SEND_VAL                                                 'sample.filter'
          9        SEND_VAL                                                 'SampleFilter'
         10        DO_ICALL                                                 
   33    11        ASSIGN                                                   !0, 'php%3A%2F%2Ffilter%2Fread%3Dsample.filter%2Fresource%3D%2Fin%2FjEMEE'
   35    12        INIT_FCALL                                               'file_get_contents'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $6      
         15        ASSIGN                                                   !1, $6
   36    16        ECHO                                                     '%3Cpre%3E'
         17        INIT_FCALL                                               'htmlentities'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $8      
         20        ECHO                                                     $8
         21        ECHO                                                     '%3C%2Fpre%3E'
   38    22        INCLUDE_OR_EVAL                                          !0, INCLUDE
   39    23    > > 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 = 43
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
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:  45
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, ->43
   19    20    >   FETCH_OBJ_R                                      ~12     'data'
         21        STRLEN                                           ~13     ~12
         22        ASSIGN                                                   !2, ~13
   21    23        INIT_FCALL                                               'str_replace'
         24        SEND_VAL                                                 'bug'
         25        SEND_VAL                                                 'feature'
         26        FETCH_OBJ_R                                      ~16     'data'
         27        SEND_VAL                                                 ~16
         28        DO_ICALL                                         $17     
         29        ASSIGN_OBJ                                               'data'
         30        OP_DATA                                                  $17
   23    31        INIT_FCALL                                               'stream_bucket_new'
         32        FETCH_OBJ_R                                      ~18     'stream'
         33        SEND_VAL                                                 ~18
         34        FETCH_OBJ_R                                      ~19     'data'
         35        SEND_VAL                                                 ~19
         36        DO_ICALL                                         $20     
         37        ASSIGN                                                   !4, $20
   24    38        INIT_FCALL                                               'stream_bucket_append'
         39        SEND_VAR                                                 !1
         40        SEND_VAR                                                 !4
         41        DO_ICALL                                                 
   26    42      > RETURN                                                   2
   29    43    > > RETURN                                                   1
   30    44*     > RETURN                                                   null

End of function filter

End of class SampleFilter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.67 ms | 1400 KiB | 31 Q