3v4l.org

run code in 500+ PHP versions simultaneously
<?php namespace Example; function substr_replace( array|string $string, array|string $replace, array|int|null $offset, array|int|null $length = null ): string|array { if ( $offset === null ) { $offset = is_string($string) ? strlen($string) : array_map(strlen(...), $string); } return \substr_replace($string, $replace, $offset, $length); } $foo = substr_replace('abc', 'xyz', null); var_dump($foo); $foo = substr_replace(['hello', 'goodbye'], '!', null); var_dump($foo); $foo = substr_replace(['one', 'two'], [' - uno', ' - dos'], null); var_dump($foo);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6eEIG
function name:  (null)
number of ops:  28
compiled vars:  !0 = $foo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   INIT_NS_FCALL_BY_NAME                                        'Example%5Csubstr_replace'
          1        SEND_VAL_EX                                                  'abc'
          2        SEND_VAL_EX                                                  'xyz'
          3        SEND_VAL_EX                                                  null
          4        DO_FCALL                                          0  $1      
          5        ASSIGN                                                       !0, $1
   21     6        INIT_NS_FCALL_BY_NAME                                        'Example%5Cvar_dump'
          7        SEND_VAR_EX                                                  !0
          8        DO_FCALL                                          0          
   23     9        INIT_NS_FCALL_BY_NAME                                        'Example%5Csubstr_replace'
         10        SEND_VAL_EX                                                  <array>
         11        SEND_VAL_EX                                                  '%21'
         12        SEND_VAL_EX                                                  null
         13        DO_FCALL                                          0  $4      
         14        ASSIGN                                                       !0, $4
   24    15        INIT_NS_FCALL_BY_NAME                                        'Example%5Cvar_dump'
         16        SEND_VAR_EX                                                  !0
         17        DO_FCALL                                          0          
   26    18        INIT_NS_FCALL_BY_NAME                                        'Example%5Csubstr_replace'
         19        SEND_VAL_EX                                                  <array>
         20        SEND_VAL_EX                                                  <array>
         21        SEND_VAL_EX                                                  null
         22        DO_FCALL                                          0  $7      
         23        ASSIGN                                                       !0, $7
   27    24        INIT_NS_FCALL_BY_NAME                                        'Example%5Cvar_dump'
         25        SEND_VAR_EX                                                  !0
         26        DO_FCALL                                          0          
         27      > RETURN                                                       1

Function example%5Csubstr_replace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 23
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/6eEIG
function name:  Example\substr_replace
number of ops:  33
compiled vars:  !0 = $string, !1 = $replace, !2 = $offset, !3 = $length
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
    7     1        RECV                                                 !1      
    8     2        RECV                                                 !2      
    9     3        RECV_INIT                                            !3      null
   11     4        TYPE_CHECK                                        2          !2
          5      > JMPZ                                                         ~4, ->23
   12     6    >   INIT_NS_FCALL_BY_NAME                                        'Example%5Cis_string'
          7        SEND_VAR_EX                                                  !0
          8        DO_FCALL                                          0  $5      
          9      > JMPZ                                                         $5, ->15
   13    10    >   INIT_NS_FCALL_BY_NAME                                        'Example%5Cstrlen'
         11        SEND_VAR_EX                                                  !0
         12        DO_FCALL                                          0  $6      
         13        QM_ASSIGN                                            ~7      $6
         14      > JMP                                                          ->22
   14    15    >   INIT_NS_FCALL_BY_NAME                                        'Example%5Carray_map'
         16        INIT_NS_FCALL_BY_NAME                                        'Example%5Cstrlen'
         17        CALLABLE_CONVERT                                     ~8      
         18        SEND_VAL_EX                                                  ~8
         19        SEND_VAR_EX                                                  !0
         20        DO_FCALL                                          0  $9      
         21        QM_ASSIGN                                            ~7      $9
   12    22    >   ASSIGN                                                       !2, ~7
   16    23    >   INIT_FCALL                                                   'substr_replace'
         24        SEND_VAR                                                     !0
         25        SEND_VAR                                                     !1
         26        SEND_VAR                                                     !2
         27        SEND_VAR                                                     !3
         28        DO_ICALL                                             $11     
         29        VERIFY_RETURN_TYPE                                           $11
         30      > RETURN                                                       $11
   17    31*       VERIFY_RETURN_TYPE                                           
         32*     > RETURN                                                       null

End of function example%5Csubstr_replace

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.96 ms | 1582 KiB | 18 Q