3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mystr_replace($needle,$replace,$haystack){ $args = func_get_args(); $count=null; if(isset($args[3])){ $count &= $args[3]; } var_dump($args); if(is_null($count)) { return str_replace($needle,$replace,$haystack); } else { return str_replace($needle,$replace,$haystack,$count); } } echo mystr_replace("frop","frml","fropfrop")."\n"; echo mystr_replace("frop","frml","fropfrop",1)."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GF93C
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'mystr_replace'
          1        SEND_VAL                                                 'frop'
          2        SEND_VAL                                                 'frml'
          3        SEND_VAL                                                 'fropfrop'
          4        DO_FCALL                                      0  $0      
          5        CONCAT                                           ~1      $0, '%0A'
          6        ECHO                                                     ~1
   17     7        INIT_FCALL                                               'mystr_replace'
          8        SEND_VAL                                                 'frop'
          9        SEND_VAL                                                 'frml'
         10        SEND_VAL                                                 'fropfrop'
         11        SEND_VAL                                                 1
         12        DO_FCALL                                      0  $2      
         13        CONCAT                                           ~3      $2, '%0A'
         14        ECHO                                                     ~3
         15      > RETURN                                                   1

Function mystr_replace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/GF93C
function name:  mystr_replace
number of ops:  30
compiled vars:  !0 = $needle, !1 = $replace, !2 = $haystack, !3 = $args, !4 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    3     3        FUNC_GET_ARGS                                    ~5      
          4        ASSIGN                                                   !3, ~5
    4     5        ASSIGN                                                   !4, null
    5     6        ISSET_ISEMPTY_DIM_OBJ                         0          !3, 3
          7      > JMPZ                                                     ~8, ->10
    6     8    >   FETCH_DIM_R                                      ~9      !3, 3
          9        ASSIGN_OP                                    10          !4, ~9
    8    10    >   INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                                 
    9    13        TYPE_CHECK                                    2          !4
         14      > JMPZ                                                     ~12, ->22
   10    15    >   INIT_FCALL                                               'str_replace'
         16        SEND_VAR                                                 !0
         17        SEND_VAR                                                 !1
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $13     
         20      > RETURN                                                   $13
         21*       JMP                                                      ->29
   12    22    >   INIT_FCALL                                               'str_replace'
         23        SEND_VAR                                                 !0
         24        SEND_VAR                                                 !1
         25        SEND_VAR                                                 !2
         26        SEND_REF                                                 !4
         27        DO_ICALL                                         $14     
         28      > RETURN                                                   $14
   14    29*     > RETURN                                                   null

End of function mystr_replace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.03 ms | 1403 KiB | 19 Q