3v4l.org

run code in 300+ PHP versions simultaneously
<?php $patternCallbacks = [ '~\[code](.*?)\[/code]~is' => function($m) { return '[code]' . base64_encode($m[1]) . '[/code]'; }, '~\[php(?:=[0-9]+)?]\K(.*?)\[/php]~is' => function($m) { return base64_encode($m[1]) . '[/php]'; }, ]; $text = <<<TEXT This is my [code]script[/code] to display. It has [php]unnumbered tag code[/php] and [php=8]numbered tag code[/php].' TEXT; foreach ($patternCallbacks as $pattern => $callback) { $text = preg_replace_callback($pattern, $callback, $text); } echo $text;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/cMcYh
function name:  (null)
number of ops:  19
compiled vars:  !0 = $patternCallbacks, !1 = $text, !2 = $callback, !3 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_LAMBDA_FUNCTION                          ~4      [0]
    7     1        INIT_ARRAY                                       ~5      ~4, '%7E%5C%5Bcode%5D%28.%2A%3F%29%5C%5B%2Fcode%5D%7Eis'
    9     2        DECLARE_LAMBDA_FUNCTION                          ~6      [1]
   11     3        ADD_ARRAY_ELEMENT                                ~5      ~6, '%7E%5C%5Bphp%28%3F%3A%3D%5B0-9%5D%2B%29%3F%5D%5CK%28.%2A%3F%29%5C%5B%2Fphp%5D%7Eis'
    3     4        ASSIGN                                                   !0, ~5
   14     5        ASSIGN                                                   !1, 'This+is+my+%5Bcode%5Dscript%5B%2Fcode%5D+to+display.%0AIt+has+%5Bphp%5Dunnumbered+tag%0A+code%5B%2Fphp%5D+and+%5Bphp%3D8%5Dnumbered+tag+code%5B%2Fphp%5D.%27'
   20     6      > FE_RESET_R                                       $9      !0, ->16
          7    > > FE_FETCH_R                                       ~10     $9, !2, ->16
          8    >   ASSIGN                                                   !3, ~10
   21     9        INIT_FCALL                                               'preg_replace_callback'
         10        SEND_VAR                                                 !3
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $12     
         14        ASSIGN                                                   !1, $12
   20    15      > JMP                                                      ->7
         16    >   FE_FREE                                                  $9
   23    17        ECHO                                                     !1
   24    18      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cMcYh
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'base64_encode'
          2        FETCH_DIM_R                                      ~1      !0, 1
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        CONCAT                                           ~3      '%5Bcode%5D', $2
          6        CONCAT                                           ~4      ~3, '%5B%2Fcode%5D'
          7      > RETURN                                                   ~4
    7     8*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cMcYh
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'base64_encode'
          2        FETCH_DIM_R                                      ~1      !0, 1
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        CONCAT                                           ~3      $2, '%5B%2Fphp%5D'
          6      > RETURN                                                   ~3
   11     7*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.43 ms | 1011 KiB | 15 Q