3v4l.org

run code in 500+ PHP versions simultaneously
<?php $string = "An elephant is an elephant"; print str_replace('ph', 'php', $string); print PHP_EOL; $closure = function() { static $count = 0; ++$count; return $count === 2 ? 'php' : 'ph'; }; print preg_replace_callback('/ph/', $closure, $string); print PHP_EOL; $pos1 = strpos($string, 'ph'); $pos2 = strpos($string, 'ph', $pos1 + 3); print substr_replace($string, 'php', $pos2, strlen('ph'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oWmJt
function name:  (null)
number of ops:  28
compiled vars:  !0 = $string, !1 = $closure, !2 = $pos1, !3 = $pos2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'An+elephant+is+an+elephant'
    5     1        FRAMELESS_ICALL_3                str_replace         ~5      'ph', 'php'
          2        OP_DATA                                                      !0
          3        ECHO                                                         ~5
    6     4        ECHO                                                         '%0A'
    7     5        DECLARE_LAMBDA_FUNCTION                              ~6      [0]
          6        ASSIGN                                                       !1, ~6
   13     7        INIT_FCALL                                                   'preg_replace_callback'
          8        SEND_VAL                                                     '%2Fph%2F'
          9        SEND_VAR                                                     !1
         10        SEND_VAR                                                     !0
         11        DO_ICALL                                             $8      
         12        ECHO                                                         $8
   14    13        ECHO                                                         '%0A'
   15    14        FRAMELESS_ICALL_2                strpos              ~9      !0, 'ph'
         15        ASSIGN                                                       !2, ~9
   16    16        ADD                                                  ~11     !2, 3
         17        FRAMELESS_ICALL_3                strpos              ~12     !0, 'ph'
         18        OP_DATA                                                      ~11
         19        ASSIGN                                                       !3, ~12
   17    20        INIT_FCALL                                                   'substr_replace'
         21        SEND_VAR                                                     !0
         22        SEND_VAL                                                     'php'
         23        SEND_VAR                                                     !3
         24        SEND_VAL                                                     2
         25        DO_ICALL                                             $14     
         26        ECHO                                                         $14
         27      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oWmJt
function name:  {closure:/in/oWmJt:7}
number of ops:  9
compiled vars:  !0 = $count
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   BIND_STATIC                                                  !0
    9     1        PRE_INC                                                      !0
   11     2        IS_IDENTICAL                                                 !0, 2
          3      > JMPZ                                                         ~2, ->6
          4    >   QM_ASSIGN                                            ~3      'php'
          5      > JMP                                                          ->7
          6    >   QM_ASSIGN                                            ~3      'ph'
          7    > > RETURN                                                       ~3
   12     8*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
127.67 ms | 485 KiB | 9 Q