3v4l.org

run code in 300+ PHP versions simultaneously
<?php class x { public $a = [ '~.~' => '$this->waa($0);' ]; function p($s) { foreach($this->a as $p => $r) { $s = preg_replace_callback($p, function($m) use ($s, $r){ $c = preg_replace('~\$(\d)~', '$m[$1]', $r); print "\n$c\n"; return eval('return '.$c); }, $s); } return $s; } function waa($t){ return '*'.$t.'*'; } } var_dump((new x)->p('wazup'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t6ec6
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'var_dump'
          1        NEW                                              $0      'x'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $0, 'p'
          4        SEND_VAL_EX                                              'wazup'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Ft6ec6%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t6ec6
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $m, !1 = $s, !2 = $r, !3 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   14     3        INIT_FCALL                                               'preg_replace'
          4        SEND_VAL                                                 '%7E%5C%24%28%5Cd%29%7E'
          5        SEND_VAL                                                 '%24m%5B%241%5D'
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !3, $4
   15     9        ROPE_INIT                                     3  ~7      '%0A'
         10        ROPE_ADD                                      1  ~7      ~7, !3
         11        ROPE_END                                      2  ~6      ~7, '%0A'
         12        ECHO                                                     ~6
   17    13        CONCAT                                           ~9      'return+', !3
         14        INCLUDE_OR_EVAL                                  $10     ~9, EVAL
         15      > RETURN                                                   $10
   18    16*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Ft6ec6%3A13%240

Class x:
Function p:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/t6ec6
function name:  p
number of ops:  18
compiled vars:  !0 = $s, !1 = $r, !2 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        FETCH_OBJ_R                                      ~3      'a'
          2      > FE_RESET_R                                       $4      ~3, ->15
          3    > > FE_FETCH_R                                       ~5      $4, !1, ->15
          4    >   ASSIGN                                                   !2, ~5
   13     5        INIT_FCALL                                               'preg_replace_callback'
          6        SEND_VAR                                                 !2
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Ft6ec6%3A13%240'
          8        BIND_LEXICAL                                             ~7, !0
          9        BIND_LEXICAL                                             ~7, !1
   18    10        SEND_VAL                                                 ~7
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $8      
   13    13        ASSIGN                                                   !0, $8
   11    14      > JMP                                                      ->3
         15    >   FE_FREE                                                  $4
   21    16      > RETURN                                                   !0
   22    17*     > RETURN                                                   null

End of function p

Function waa:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t6ec6
function name:  waa
number of ops:  5
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        CONCAT                                           ~1      '%2A', !0
          2        CONCAT                                           ~2      ~1, '%2A'
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function waa

End of class x.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
296.92 ms | 1400 KiB | 20 Q