3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hello = 'Hi'; $name = 'ken'; $replacements = [ 'hello' => 'morning', 'invoiceno' => 1234 ]; $msg = '$hello, $name (JX02), Your Orders $invoiceno has been delivered. $test $123,99 $123.99 Thank you.'; $result = preg_replace_callback('/\$([\w\_-]{1,})/', function ($match) use ($replacements) { return array_key_exists($match[1], $replacements) ? $replacements[$match[1]] : ( isset($GLOBALS[$match[1]]) ? $GLOBALS[$match[1]] : '$'.$match[1] ); }, $msg); echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UMs9h
function name:  (null)
number of ops:  14
compiled vars:  !0 = $hello, !1 = $name, !2 = $replacements, !3 = $msg, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'Hi'
    3     1        ASSIGN                                                   !1, 'ken'
    5     2        ASSIGN                                                   !2, <array>
   10     3        ASSIGN                                                   !3, '%24hello%2C+%24name+%28JX02%29%2C+Your+Orders+%24invoiceno+has+been+delivered.+%24test+%24123%2C99+%24123.99+Thank+you.'
   12     4        INIT_FCALL                                               'preg_replace_callback'
          5        SEND_VAL                                                 '%2F%5C%24%28%5B%5Cw%5C_-%5D%7B1%2C%7D%29%2F'
          6        DECLARE_LAMBDA_FUNCTION                          ~9      [0]
          7        BIND_LEXICAL                                             ~9, !2
   16     8        SEND_VAL                                                 ~9
          9        SEND_VAR                                                 !3
   12    10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !4, $10
   18    12        ECHO                                                     !4
   19    13      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UMs9h
function name:  {closure}
number of ops:  22
compiled vars:  !0 = $match, !1 = $replacements
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   13     2        FETCH_DIM_R                                      ~2      !0, 1
          3        ARRAY_KEY_EXISTS                                         ~2, !1
          4      > JMPZ                                                     ~3, ->9
          5    >   FETCH_DIM_R                                      ~4      !0, 1
          6        FETCH_DIM_R                                      ~5      !1, ~4
          7        QM_ASSIGN                                        ~6      ~5
          8      > JMP                                                      ->20
   14     9    >   FETCH_DIM_R                                      ~7      !0, 1
         10        ISSET_ISEMPTY_VAR                             2          ~7
         11      > JMPZ                                                     ~8, ->16
         12    >   FETCH_DIM_R                                      ~9      !0, 1
         13        FETCH_R                      global              ~10     ~9
         14        QM_ASSIGN                                        ~11     ~10
         15      > JMP                                                      ->19
         16    >   FETCH_DIM_R                                      ~12     !0, 1
         17        CONCAT                                           ~13     '%24', ~12
         18        QM_ASSIGN                                        ~11     ~13
         19    >   QM_ASSIGN                                        ~6      ~11
         20    > > RETURN                                                   ~6
   16    21*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
120.44 ms | 1005 KiB | 14 Q