3v4l.org

run code in 300+ PHP versions simultaneously
<?php function power($s) { return array_sum(array_map(function($e) { return ord($e) - 64; }, str_split($s))); } function battle($x, $y) { $l = power($x); $m = power($y); return ($l > $m) ? $x : (($l == $m) ? "Tie!" : $y); } echo battle("FOUR", "FIVE");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CbHXa
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'battle'
          1        SEND_VAL                                                 'FOUR'
          2        SEND_VAL                                                 'FIVE'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function power:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CbHXa
function name:  power
number of ops:  14
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'array_sum'
          2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FCbHXa%3A4%240'
    6     4        SEND_VAL                                                 ~1
          5        INIT_FCALL                                               'str_split'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                         $3      
         10        SEND_VAR                                                 $3
         11        DO_ICALL                                         $4      
         12      > RETURN                                                   $4
    7    13*     > RETURN                                                   null

End of function power

Function %00%7Bclosure%7D%2Fin%2FCbHXa%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CbHXa
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'ord'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        SUB                                              ~2      $1, 64
          5      > RETURN                                                   ~2
    6     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FCbHXa%3A4%240

Function battle:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CbHXa
function name:  battle
number of ops:  22
compiled vars:  !0 = $x, !1 = $y, !2 = $l, !3 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'power'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !2, $4
   11     6        INIT_FCALL                                               'power'
          7        SEND_VAR                                                 !1
          8        DO_FCALL                                      0  $6      
          9        ASSIGN                                                   !3, $6
   13    10        IS_SMALLER                                               !3, !2
         11      > JMPZ                                                     ~8, ->14
         12    >   QM_ASSIGN                                        ~9      !0
         13      > JMP                                                      ->20
         14    >   IS_EQUAL                                                 !2, !3
         15      > JMPZ                                                     ~10, ->18
         16    >   QM_ASSIGN                                        ~11     'Tie%21'
         17      > JMP                                                      ->19
         18    >   QM_ASSIGN                                        ~11     !1
         19    >   QM_ASSIGN                                        ~9      ~11
         20    > > RETURN                                                   ~9
   14    21*     > RETURN                                                   null

End of function battle

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.51 ms | 1403 KiB | 24 Q