3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = "Lorem ABC ipsum ABC bla MNO bla ipsum ABC asfg 123 hello ABC dd ABC XYZ hello ABC"; echo preg_replace_callback('~(?<=MNO).*?(?=XYZ)~s', function($m) { return str_replace('ABC', 'XXX', $m[0]); }, $s); echo "\n"; echo preg_replace_callback('~(MNO)(.*?)(XYZ)~s', function($m) { return $m[1] . str_replace('ABC', 'XXX', $m[2]) . $m[3]; }, $s);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CBKZl
function name:  (null)
number of ops:  17
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Lorem+ABC+ipsum+ABC+bla+MNO+bla+ipsum+ABC+asfg+123+hello+ABC+dd+ABC+XYZ+hello+ABC'
    4     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%7E%28%3F%3C%3DMNO%29.%2A%3F%28%3F%3DXYZ%29%7Es'
          3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
    6     4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !0
    4     6        DO_ICALL                                         $3      
    6     7        ECHO                                                     $3
    7     8        ECHO                                                     '%0A'
    8     9        INIT_FCALL                                               'preg_replace_callback'
         10        SEND_VAL                                                 '%7E%28MNO%29%28.%2A%3F%29%28XYZ%29%7Es'
         11        DECLARE_LAMBDA_FUNCTION                          ~4      [1]
   10    12        SEND_VAL                                                 ~4
         13        SEND_VAR                                                 !0
    8    14        DO_ICALL                                         $5      
   10    15        ECHO                                                     $5
         16      > 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/CBKZl
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 'ABC'
          3        SEND_VAL                                                 'XXX'
          4        FETCH_DIM_R                                      ~1      !0, 0
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    6     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/CBKZl
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        FETCH_DIM_R                                      ~1      !0, 1
          2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 'ABC'
          4        SEND_VAL                                                 'XXX'
          5        FETCH_DIM_R                                      ~2      !0, 2
          6        SEND_VAL                                                 ~2
          7        DO_ICALL                                         $3      
          8        CONCAT                                           ~4      ~1, $3
          9        FETCH_DIM_R                                      ~5      !0, 3
         10        CONCAT                                           ~6      ~4, ~5
         11      > RETURN                                                   ~6
   10    12*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.9 ms | 1016 KiB | 15 Q