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); 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>")]; unserialize(serialize(new Post("hue", "br", [new Filter("/gibe/", "gibe moni"), new Filter("/moni/", "i repor u")]))); unserialize('O:4:"Post":3:{s:8:"*title";s:3:"hue";s:7:"*text";s:2:"br";s:10:"*filters";a:2:{i:0;O:6:"Filter":2:{s:10:"*pattern";s:6:"/gibe/";s:7:"*repl";s:9:"gibe moni";}i:1;O:6:"Filter":2:{s:10:"*pattern";s:6:"/moni/";s:7:"*repl";s:9:"i repor u";}}}');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d5k8G
function name:  (null)
number of ops:  46
compiled vars:  !0 = $standard_filter_set
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     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
   52     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
   53    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
   54    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
   51    20        ASSIGN                                                   !0, ~3
   56    21        INIT_FCALL                                               'unserialize'
         22        INIT_FCALL                                               'serialize'
         23        NEW                                              $11     'Post'
         24        SEND_VAL_EX                                              'hue'
         25        SEND_VAL_EX                                              'br'
         26        NEW                                              $12     'Filter'
         27        SEND_VAL_EX                                              '%2Fgibe%2F'
         28        SEND_VAL_EX                                              'gibe+moni'
         29        DO_FCALL                                      0          
         30        INIT_ARRAY                                       ~14     $12
         31        NEW                                              $15     'Filter'
         32        SEND_VAL_EX                                              '%2Fmoni%2F'
         33        SEND_VAL_EX                                              'i+repor+u'
         34        DO_FCALL                                      0          
         35        ADD_ARRAY_ELEMENT                                ~14     $15
         36        SEND_VAL_EX                                              ~14
         37        DO_FCALL                                      0          
         38        SEND_VAR                                                 $11
         39        DO_ICALL                                         $18     
         40        SEND_VAR                                                 $18
         41        DO_ICALL                                                 
   57    42        INIT_FCALL                                               'unserialize'
         43        SEND_VAL                                                 'O%3A4%3A%22Post%22%3A3%3A%7Bs%3A8%3A%22%2Atitle%22%3Bs%3A3%3A%22hue%22%3Bs%3A7%3A%22%2Atext%22%3Bs%3A2%3A%22br%22%3Bs%3A10%3A%22%2Afilters%22%3Ba%3A2%3A%7Bi%3A0%3BO%3A6%3A%22Filter%22%3A2%3A%7Bs%3A10%3A%22%2Apattern%22%3Bs%3A6%3A%22%2Fgibe%2F%22%3Bs%3A7%3A%22%2Arepl%22%3Bs%3A9%3A%22gibe+moni%22%3B%7Di%3A1%3BO%3A6%3A%22Filter%22%3A2%3A%7Bs%3A10%3A%22%2Apattern%22%3Bs%3A6%3A%22%2Fmoni%2F%22%3Bs%3A7%3A%22%2Arepl%22%3Bs%3A9%3A%22i+repor+u%22%3B%7D%7D%7D'
         44        DO_ICALL                                                 
         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/d5k8G
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/d5k8G
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/d5k8G
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%5Cn'
   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/d5k8G
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/d5k8G
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/d5k8G
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 = 13, Position 2 = 19
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/d5k8G
function name:  __destruct
number of ops:  27
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      > FE_RESET_R                                       $11     ~10, ->19
         13    > > FE_FETCH_R                                               $11, !2, ->19
   44    14    >   INIT_METHOD_CALL                                         !2, 'filter'
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0  $12     
         17        ASSIGN                                                   !1, $12
   43    18      > JMP                                                      ->13
         19    >   FE_FREE                                                  $11
   45    20        CONCAT                                           ~14     !0, '%3A+'
         21        CONCAT                                           ~15     ~14, !1
         22        ASSIGN                                                   !0, ~15
   46    23        CONCAT                                           ~17     !0, '+--%3E'
         24        ASSIGN                                                   !0, ~17
   47    25        ECHO                                                     !0
   48    26      > RETURN                                                   null

End of function __destruct

End of class Post.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.58 ms | 1408 KiB | 21 Q