3v4l.org

run code in 300+ PHP versions simultaneously
<?php class StreamFilter extends php_user_filter { public function filter($in, $out, &$consumed, $closing) { //var_dump('FILTERING!'); while ($bucket = stream_bucket_make_writeable($in)) ; if ($closing || feof($this->stream)) { $streamUri = substr(stream_get_meta_data($this->stream)['uri'], strlen('php://filter/read=asd/resource=')); //$buffer = strtoupper(file_get_contents($streamUri)); $buffer = 'HA'; $bucket = stream_bucket_new($this->stream, $buffer); stream_bucket_append($out, $bucket); return PSFS_PASS_ON; } return PSFS_FEED_ME; } } stream_filter_register('asd', 'StreamFilter'); function shut() { $stream = 'php://filter/read=asd/resource=/home/vagrant/test-register-shutdown-function/test.txt'; $stream = 'php://filter/read=asd/resource=/in/Yjm5O'; var_dump(file_get_contents($stream)); //$stream = 'php://filter/read=string.toupper/resource=/home/vagrant/test-register-shutdown-function/test.txt'; //var_dump(file_get_contents($stream)); } register_shutdown_function('shut'); /* class A { public function __destruct() { } } new A(); */ die;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/oprfS
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'stream_filter_register'
          1        SEND_VAL                                                 'asd'
          2        SEND_VAL                                                 'StreamFilter'
          3        DO_ICALL                                                 
   40     4        INIT_FCALL                                               'register_shutdown_function'
          5        SEND_VAL                                                 'shut'
          6        DO_ICALL                                                 
   53     7      > EXIT                                                     
          8*     > RETURN                                                   1

Function shut:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oprfS
function name:  shut
number of ops:  9
compiled vars:  !0 = $stream
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   ASSIGN                                                   !0, 'php%3A%2F%2Ffilter%2Fread%3Dasd%2Fresource%3D%2Fhome%2Fvagrant%2Ftest-register-shutdown-function%2Ftest.txt'
   33     1        ASSIGN                                                   !0, 'php%3A%2F%2Ffilter%2Fread%3Dasd%2Fresource%3D%2Fin%2FYjm5O'
   34     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'file_get_contents'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
   38     8      > RETURN                                                   null

End of function shut

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

End of function filter

End of class StreamFilter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
291.68 ms | 1405 KiB | 34 Q