3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getRidOfPrefix($data, $prefix) { if (strpos($data, $prefix) === 0) { return substr($data, strlen($prefix) - 1); } return $data; } echo getRidOfPrefix("something", "so") . "\n"; echo getRidOfPrefix("something", "th");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P33Xg
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'getridofprefix'
          1        SEND_VAL                                                 'something'
          2        SEND_VAL                                                 'so'
          3        DO_FCALL                                      0  $0      
          4        CONCAT                                           ~1      $0, '%0A'
          5        ECHO                                                     ~1
   11     6        INIT_FCALL                                               'getridofprefix'
          7        SEND_VAL                                                 'something'
          8        SEND_VAL                                                 'th'
          9        DO_FCALL                                      0  $2      
         10        ECHO                                                     $2
         11      > RETURN                                                   1

Function getridofprefix:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P33Xg
function name:  getRidOfPrefix
number of ops:  17
compiled vars:  !0 = $data, !1 = $prefix
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'strpos'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6        IS_IDENTICAL                                             $2, 0
          7      > JMPZ                                                     ~3, ->15
    5     8    >   INIT_FCALL                                               'substr'
          9        SEND_VAR                                                 !0
         10        STRLEN                                           ~4      !1
         11        SUB                                              ~5      ~4, 1
         12        SEND_VAL                                                 ~5
         13        DO_ICALL                                         $6      
         14      > RETURN                                                   $6
    7    15    > > RETURN                                                   !0
    8    16*     > RETURN                                                   null

End of function getridofprefix

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.1 ms | 1399 KiB | 19 Q