3v4l.org

run code in 300+ PHP versions simultaneously
<?php function happy($num){ $digs = (string) $num; $sum = 0; foreach(explode('', $digs) as $dig){ $sum == $dig; } return $sum; } echo happy(31);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/q2o1M
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'happy'
          1        SEND_VAL                                                 31
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function happy:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/q2o1M
function name:  happy
number of ops:  16
compiled vars:  !0 = $num, !1 = $digs, !2 = $sum, !3 = $dig
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        CAST                                          6  ~4      !0
          2        ASSIGN                                                   !1, ~4
    5     3        ASSIGN                                                   !2, 0
    6     4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 ''
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $7      
          8      > FE_RESET_R                                       $8      $7, ->13
          9    > > FE_FETCH_R                                               $8, !3, ->13
    7    10    >   IS_EQUAL                                         ~9      !2, !3
         11        FREE                                                     ~9
    6    12      > JMP                                                      ->9
         13    >   FE_FREE                                                  $8
    9    14      > RETURN                                                   !2
   10    15*     > RETURN                                                   null

End of function happy

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.99 ms | 1398 KiB | 16 Q