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); } }; 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")])));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Oo0el
function name:  (null)
number of ops:  43
compiled vars:  !0 = $standard_filter_set
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     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
   49     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
   50    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
   51    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
   48    20        ASSIGN                                                   !0, ~3
   53    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                                                 
         42      > RETURN                                                   1

Class Filter:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Oo0el
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/Oo0el
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

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/Oo0el
function name:  __construct
number of ops:  10
compiled vars:  !0 = $title, !1 = $text, !2 = $filters
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   20     3        ASSIGN_OBJ                                               'title'
          4        OP_DATA                                                  !0
   21     5        ASSIGN_OBJ                                               'text'
          6        OP_DATA                                                  !1
   22     7        ASSIGN_OBJ                                               'filters'
          8        OP_DATA                                                  !2
   23     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/Oo0el
function name:  get_title
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'htmlspecialchars'
          1        FETCH_OBJ_R                                      ~0      'title'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   27     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/Oo0el
function name:  display_post
number of ops:  16
compiled vars:  !0 = $text, !1 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_FCALL                                               'htmlspecialchars'
          1        FETCH_OBJ_R                                      ~2      'text'
          2        SEND_VAL                                                 ~2
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
   31     5        FETCH_OBJ_R                                      ~5      'filters'
          6      > FE_RESET_R                                       $6      ~5, ->13
          7    > > FE_FETCH_R                                               $6, !1, ->13
   32     8    >   INIT_METHOD_CALL                                         !1, 'filter'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $7      
         11        ASSIGN                                                   !0, $7
   31    12      > JMP                                                      ->7
         13    >   FE_FREE                                                  $6
   33    14      > RETURN                                                   !0
   34    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/Oo0el
function name:  __destruct
number of ops:  27
compiled vars:  !0 = $s, !1 = $text, !2 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     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
   39     6        INIT_FCALL                                               'htmlspecialchars'
          7        FETCH_OBJ_R                                      ~7      'text'
          8        SEND_VAL                                                 ~7
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !1, $8
   40    11        FETCH_OBJ_R                                      ~10     'filters'
         12      > FE_RESET_R                                       $11     ~10, ->19
         13    > > FE_FETCH_R                                               $11, !2, ->19
   41    14    >   INIT_METHOD_CALL                                         !2, 'filter'
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0  $12     
         17        ASSIGN                                                   !1, $12
   40    18      > JMP                                                      ->13
         19    >   FE_FREE                                                  $11
   42    20        CONCAT                                           ~14     !0, '%3A+'
         21        CONCAT                                           ~15     ~14, !1
         22        ASSIGN                                                   !0, ~15
   43    23        CONCAT                                           ~17     !0, '+--%3E'
         24        ASSIGN                                                   !0, ~17
   44    25        ECHO                                                     !0
   45    26      > RETURN                                                   null

End of function __destruct

End of class Post.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.09 ms | 1400 KiB | 21 Q