3v4l.org

run code in 300+ PHP versions simultaneously
<?php $body = "This is a body of {{awesome}} text {{blabla}} from a book."; //$count = 0; $terms[] = '1'; $terms[] = '2'; echo preg_replace_callback('/\{{2}(.*?)\}{2}/',function($match) use (&$count,$terms) { $return = !empty($terms[$count]) ? $terms[$count] : 'Default value for unknown term'; // $count++; echo "#$count#"; return $return; }, $body, -1, $count);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m4oo3
function name:  (null)
number of ops:  17
compiled vars:  !0 = $body, !1 = $terms, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'This+is+a+body+of+%7B%7Bawesome%7D%7D+text+%7B%7Bblabla%7D%7D+from+a+book.'
    4     1        ASSIGN_DIM                                               !1
          2        OP_DATA                                                  '1'
    5     3        ASSIGN_DIM                                               !1
          4        OP_DATA                                                  '2'
    6     5        INIT_FCALL                                               'preg_replace_callback'
          6        SEND_VAL                                                 '%2F%5C%7B%7B2%7D%28.%2A%3F%29%5C%7D%7B2%7D%2F'
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fm4oo3%3A6%240'
          8        BIND_LEXICAL                                             ~6, !2
          9        BIND_LEXICAL                                             ~6, !1
   11    10        SEND_VAL                                                 ~6
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 -1
         13        SEND_REF                                                 !2
         14        DO_ICALL                                         $7      
         15        ECHO                                                     $7
         16      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fm4oo3%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m4oo3
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $match, !1 = $count, !2 = $terms, !3 = $return
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
    7     3        ISSET_ISEMPTY_DIM_OBJ                         1  ~4      !2, !1
          4        BOOL_NOT                                         ~5      ~4
          5      > JMPZ                                                     ~5, ->9
          6    >   FETCH_DIM_R                                      ~6      !2, !1
          7        QM_ASSIGN                                        ~7      ~6
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~7      'Default+value+for+unknown+term'
         10    >   ASSIGN                                                   !3, ~7
    9    11        ROPE_INIT                                     3  ~10     '%23'
         12        ROPE_ADD                                      1  ~10     ~10, !1
         13        ROPE_END                                      2  ~9      ~10, '%23'
         14        ECHO                                                     ~9
   10    15      > RETURN                                                   !3
   11    16*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fm4oo3%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.57 ms | 1400 KiB | 15 Q