3v4l.org

run code in 300+ PHP versions simultaneously
<?php class F extends php_user_filter { public function onCreate() { echo 'filter onCreate' . PHP_EOL; return true; } public function onClose() { echo 'filter onClose' . PHP_EOL; } public function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $bucket->data = strtoupper($bucket->data); $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); } echo 'filtered ' . ($consumed ? $consumed : 0) . ' bytes'; if ($closing) { echo ' and closing.'; } else { echo '.'; } if (feof($this->stream)) { echo ' Stream has reached end-of-file.'; } echo PHP_EOL; return PSFS_PASS_ON; } } stream_filter_register('f', 'F'); $str = str_repeat('a', 8320); echo 'tmpfile()' . PHP_EOL; $f1 = tmpfile(); fwrite($f1, $str); fseek($f1, 0, SEEK_SET); stream_filter_append($f1, 'f', STREAM_FILTER_READ); echo stream_get_contents($f1) . PHP_EOL; fclose($f1); echo PHP_EOL . PHP_EOL; echo 'php://temp' . PHP_EOL; $f2 = fopen('php://temp', 'r+b'); fwrite($f2, $str); fseek($f2, 0, SEEK_SET); stream_filter_append($f2, 'f', STREAM_FILTER_READ); echo stream_get_contents($f2) . PHP_EOL; fclose($f2); echo PHP_EOL . PHP_EOL; echo 'php://memory' . PHP_EOL; $f3 = fopen('php://memory', 'r+b'); fwrite($f3, $str); fseek($f3, 0, SEEK_SET); stream_filter_append($f3, 'f', STREAM_FILTER_READ); echo stream_get_contents($f3) . PHP_EOL; fclose($f3); echo PHP_EOL;

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/egsEi
function name:  (null)
number of ops:  95
compiled vars:  !0 = $str, !1 = $f1, !2 = $f2, !3 = $f3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_FCALL                                               'stream_filter_register'
          1        SEND_VAL                                                 'f'
          2        SEND_VAL                                                 'F'
          3        DO_ICALL                                                 
   39     4        INIT_FCALL                                               'str_repeat'
          5        SEND_VAL                                                 'a'
          6        SEND_VAL                                                 8320
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !0, $5
   41     9        ECHO                                                     'tmpfile%28%29%0A'
   42    10        INIT_FCALL                                               'tmpfile'
         11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !1, $7
   43    13        INIT_FCALL                                               'fwrite'
         14        SEND_VAR                                                 !1
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                                 
   44    17        INIT_FCALL                                               'fseek'
         18        SEND_VAR                                                 !1
         19        SEND_VAL                                                 0
         20        SEND_VAL                                                 0
         21        DO_ICALL                                                 
   45    22        INIT_FCALL                                               'stream_filter_append'
         23        SEND_VAR                                                 !1
         24        SEND_VAL                                                 'f'
         25        SEND_VAL                                                 1
         26        DO_ICALL                                                 
   46    27        INIT_FCALL                                               'stream_get_contents'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $12     
         30        CONCAT                                           ~13     $12, '%0A'
         31        ECHO                                                     ~13
   47    32        INIT_FCALL                                               'fclose'
         33        SEND_VAR                                                 !1
         34        DO_ICALL                                                 
   49    35        ECHO                                                     '%0A%0A'
   50    36        ECHO                                                     'php%3A%2F%2Ftemp%0A'
   51    37        INIT_FCALL                                               'fopen'
         38        SEND_VAL                                                 'php%3A%2F%2Ftemp'
         39        SEND_VAL                                                 'r%2Bb'
         40        DO_ICALL                                         $15     
         41        ASSIGN                                                   !2, $15
   52    42        INIT_FCALL                                               'fwrite'
         43        SEND_VAR                                                 !2
         44        SEND_VAR                                                 !0
         45        DO_ICALL                                                 
   53    46        INIT_FCALL                                               'fseek'
         47        SEND_VAR                                                 !2
         48        SEND_VAL                                                 0
         49        SEND_VAL                                                 0
         50        DO_ICALL                                                 
   54    51        INIT_FCALL                                               'stream_filter_append'
         52        SEND_VAR                                                 !2
         53        SEND_VAL                                                 'f'
         54        SEND_VAL                                                 1
         55        DO_ICALL                                                 
   55    56        INIT_FCALL                                               'stream_get_contents'
         57        SEND_VAR                                                 !2
         58        DO_ICALL                                         $20     
         59        CONCAT                                           ~21     $20, '%0A'
         60        ECHO                                                     ~21
   56    61        INIT_FCALL                                               'fclose'
         62        SEND_VAR                                                 !2
         63        DO_ICALL                                                 
   58    64        ECHO                                                     '%0A%0A'
   59    65        ECHO                                                     'php%3A%2F%2Fmemory%0A'
   60    66        INIT_FCALL                                               'fopen'
         67        SEND_VAL                                                 'php%3A%2F%2Fmemory'
         68        SEND_VAL                                                 'r%2Bb'
         69        DO_ICALL                                         $23     
         70        ASSIGN                                                   !3, $23
   61    71        INIT_FCALL                                               'fwrite'
         72        SEND_VAR                                                 !3
         73        SEND_VAR                                                 !0
         74        DO_ICALL                                                 
   62    75        INIT_FCALL                                               'fseek'
         76        SEND_VAR                                                 !3
         77        SEND_VAL                                                 0
         78        SEND_VAL                                                 0
         79        DO_ICALL                                                 
   63    80        INIT_FCALL                                               'stream_filter_append'
         81        SEND_VAR                                                 !3
         82        SEND_VAL                                                 'f'
         83        SEND_VAL                                                 1
         84        DO_ICALL                                                 
   64    85        INIT_FCALL                                               'stream_get_contents'
         86        SEND_VAR                                                 !3
         87        DO_ICALL                                         $28     
         88        CONCAT                                           ~29     $28, '%0A'
         89        ECHO                                                     ~29
   65    90        INIT_FCALL                                               'fclose'
         91        SEND_VAR                                                 !3
         92        DO_ICALL                                                 
   66    93        ECHO                                                     '%0A'
   67    94      > RETURN                                                   1

Class F:
Function oncreate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/egsEi
function name:  onCreate
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ECHO                                                     'filter+onCreate%0A'
    8     1      > RETURN                                                   <true>
    9     2*     > RETURN                                                   null

End of function oncreate

Function onclose:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/egsEi
function name:  onClose
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ECHO                                                     'filter+onClose%0A'
   14     1      > RETURN                                                   null

End of function onclose

Function filter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 5
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 39
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 39
Branch analysis from position: 38
Branch analysis from position: 39
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
Branch analysis from position: 32
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 5
Branch analysis from position: 22
Branch analysis from position: 5
filename:       /in/egsEi
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
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   18     4      > JMP                                                      ->17
   19     5    >   INIT_FCALL                                               'strtoupper'
          6        FETCH_OBJ_R                                      ~6      !4, 'data'
          7        SEND_VAL                                                 ~6
          8        DO_ICALL                                         $7      
          9        ASSIGN_OBJ                                               !4, 'data'
         10        OP_DATA                                                  $7
   20    11        FETCH_OBJ_R                                      ~8      !4, 'datalen'
         12        ASSIGN_OP                                     1          !2, ~8
   21    13        INIT_FCALL                                               'stream_bucket_append'
         14        SEND_VAR                                                 !1
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                                 
   18    17    >   INIT_FCALL                                               'stream_bucket_make_writeable'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $11     
         20        ASSIGN                                           ~12     !4, $11
         21      > JMPNZ                                                    ~12, ->5
   23    22    > > JMPZ                                                     !2, ->25
         23    >   QM_ASSIGN                                        ~13     !2
         24      > JMP                                                      ->26
         25    >   QM_ASSIGN                                        ~13     0
         26    >   CONCAT                                           ~14     'filtered+', ~13
         27        CONCAT                                           ~15     ~14, '+bytes'
         28        ECHO                                                     ~15
   24    29      > JMPZ                                                     !3, ->32
   25    30    >   ECHO                                                     '+and+closing.'
   24    31      > JMP                                                      ->33
   27    32    >   ECHO                                                     '.'
   29    33    >   INIT_FCALL                                               'feof'
         34        FETCH_OBJ_R                                      ~16     'stream'
         35        SEND_VAL                                                 ~16
         36        DO_ICALL                                         $17     
         37      > JMPZ                                                     $17, ->39
   30    38    >   ECHO                                                     '+Stream+has+reached+end-of-file.'
   32    39    >   ECHO                                                     '%0A'
   33    40      > RETURN                                                   2
   34    41*     > RETURN                                                   null

End of function filter

End of class F.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.72 ms | 1024 KiB | 26 Q