3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _deep_replace( $search, $subject ) { $subject = (string) $subject; $count = 1; while ( $count ) { $subject = str_replace( $search, '', $subject, $count ); } return $subject; } $foo = 'SCRSCRISCRISCRIPTPTPTIPT'; var_dump( str_replace( 'SCRIPT', '', $foo ) ); var_dump( _deep_replace( 'SCRIPT', $foo ) ); var_dump( preg_replace('/%SCRIPT+/', '', $foo ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D66nk
function name:  (null)
number of ops:  25
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, 'SCRSCRISCRISCRIPTPTPTIPT'
   13     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 'SCRIPT'
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
   14     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               '_deep_replace'
         11        SEND_VAL                                                 'SCRIPT'
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0  $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                                 
   15    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'preg_replace'
         18        SEND_VAL                                                 '%2F%25SCRIPT%2B%2F'
         19        SEND_VAL                                                 ''
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Function _deep_replace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 6
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 6
Branch analysis from position: 14
Branch analysis from position: 6
filename:       /in/D66nk
function name:  _deep_replace
number of ops:  16
compiled vars:  !0 = $search, !1 = $subject, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        CAST                                          6  ~3      !1
          3        ASSIGN                                                   !1, ~3
    5     4        ASSIGN                                                   !2, 1
    6     5      > JMP                                                      ->13
    7     6    >   INIT_FCALL                                               'str_replace'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 ''
          9        SEND_VAR                                                 !1
         10        SEND_REF                                                 !2
         11        DO_ICALL                                         $6      
         12        ASSIGN                                                   !1, $6
    6    13    > > JMPNZ                                                    !2, ->6
   10    14    > > RETURN                                                   !1
   11    15*     > RETURN                                                   null

End of function _deep_replace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.33 ms | 1403 KiB | 20 Q