3v4l.org

run code in 300+ PHP versions simultaneously
<?php // calculate sum of ordinal values of chars // starting from $start until the end of $str function charsum($str, $start) { $sum = 0; for ($i = $start, $max = strlen($str); $i < $max; ++$i) { $sum += ord($str[$i]); } return $sum; } $str = 'hello world'; echo charsum($str, strpos($str, 'x'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4oqZi
function name:  (null)
number of ops:  11
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, 'hello+world'
   15     1        INIT_FCALL                                               'charsum'
          2        SEND_VAR                                                 !0
          3        INIT_FCALL                                               'strpos'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'x'
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_FCALL                                      0  $3      
          9        ECHO                                                     $3
         10      > RETURN                                                   1

Function charsum:
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 = 15, Position 2 = 7
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 7
Branch analysis from position: 15
Branch analysis from position: 7
filename:       /in/4oqZi
function name:  charsum
number of ops:  17
compiled vars:  !0 = $str, !1 = $start, !2 = $sum, !3 = $i, !4 = $max
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN                                                   !2, 0
    8     3        ASSIGN                                                   !3, !1
          4        STRLEN                                           ~7      !0
          5        ASSIGN                                                   !4, ~7
          6      > JMP                                                      ->13
    9     7    >   INIT_FCALL                                               'ord'
          8        FETCH_DIM_R                                      ~9      !0, !3
          9        SEND_VAL                                                 ~9
         10        DO_ICALL                                         $10     
         11        ASSIGN_OP                                     1          !2, $10
    8    12        PRE_INC                                                  !3
         13    >   IS_SMALLER                                               !3, !4
         14      > JMPNZ                                                    ~13, ->7
   11    15    > > RETURN                                                   !2
   12    16*     > RETURN                                                   null

End of function charsum

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.02 ms | 1399 KiB | 18 Q