3v4l.org

run code in 300+ PHP versions simultaneously
<?php function time_diff($s) { $m = 0; $hr = 0; $d = 0; $td = "now"; if ($s > 59) { $m = (int)($s/60); $s = $s-($m*60); // sec left over $td = "$m min"; } if ($m > 59) { $hr = (int)($m / 60); $m = $m - ($hr*60); // min left over $td = "$hr hr"; if ($hr > 1) { $td .= "s"; } if ($m > 0) { $td .= ", $m min"; } } if ($hr > 23) { $d = (int) ($hr / 24); $hr = $hr-($d*24); // hr left over $td = "$d day"; if ($d > 1) { $td .= "s"; } if ($d < 3) { if ($hr > 0) { $td .= ", $hr hr"; } if ($hr > 1) { $td .= "s"; } } } return $td; } $diffInSecs = strtotime('14:00') - strtotime('9:15'); $hours = $diffInSecs / 3600; echo $hours; echo "<br>"; echo time_diff($diffInSecs);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cFUQ6
function name:  (null)
number of ops:  17
compiled vars:  !0 = $diffInSecs, !1 = $hours
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   INIT_FCALL                                               'strtotime'
          1        SEND_VAL                                                 '14%3A00'
          2        DO_ICALL                                         $2      
          3        INIT_FCALL                                               'strtotime'
          4        SEND_VAL                                                 '9%3A15'
          5        DO_ICALL                                         $3      
          6        SUB                                              ~4      $2, $3
          7        ASSIGN                                                   !0, ~4
   41     8        DIV                                              ~6      !0, 3600
          9        ASSIGN                                                   !1, ~6
   42    10        ECHO                                                     !1
   43    11        ECHO                                                     '%3Cbr%3E'
   44    12        INIT_FCALL                                               'time_diff'
         13        SEND_VAR                                                 !0
         14        DO_FCALL                                      0  $8      
         15        ECHO                                                     $8
         16      > RETURN                                                   1

Function time_diff:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 36
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 36
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 61
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 50
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 61
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 58
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 61
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
Branch analysis from position: 58
Branch analysis from position: 61
Branch analysis from position: 50
Branch analysis from position: 61
Branch analysis from position: 36
Branch analysis from position: 30
Branch analysis from position: 36
Branch analysis from position: 16
filename:       /in/cFUQ6
function name:  time_diff
number of ops:  63
compiled vars:  !0 = $s, !1 = $m, !2 = $hr, !3 = $d, !4 = $td
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, 0
          2        ASSIGN                                                   !2, 0
          3        ASSIGN                                                   !3, 0
          4        ASSIGN                                                   !4, 'now'
    5     5        IS_SMALLER                                               59, !0
          6      > JMPZ                                                     ~9, ->16
    6     7    >   DIV                                              ~10     !0, 60
          8        CAST                                          4  ~11     ~10
          9        ASSIGN                                                   !1, ~11
    7    10        MUL                                              ~13     !1, 60
         11        SUB                                              ~14     !0, ~13
         12        ASSIGN                                                   !0, ~14
    8    13        NOP                                                      
         14        FAST_CONCAT                                      ~16     !1, '+min'
         15        ASSIGN                                                   !4, ~16
   10    16    >   IS_SMALLER                                               59, !1
         17      > JMPZ                                                     ~18, ->36
   11    18    >   DIV                                              ~19     !1, 60
         19        CAST                                          4  ~20     ~19
         20        ASSIGN                                                   !2, ~20
   12    21        MUL                                              ~22     !2, 60
         22        SUB                                              ~23     !1, ~22
         23        ASSIGN                                                   !1, ~23
   13    24        NOP                                                      
         25        FAST_CONCAT                                      ~25     !2, '+hr'
         26        ASSIGN                                                   !4, ~25
   14    27        IS_SMALLER                                               1, !2
         28      > JMPZ                                                     ~27, ->30
   15    29    >   ASSIGN_OP                                     8          !4, 's'
   17    30    >   IS_SMALLER                                               0, !1
         31      > JMPZ                                                     ~29, ->36
   18    32    >   ROPE_INIT                                     3  ~31     '%2C+'
         33        ROPE_ADD                                      1  ~31     ~31, !1
         34        ROPE_END                                      2  ~30     ~31, '+min'
         35        ASSIGN_OP                                     8          !4, ~30
   21    36    >   IS_SMALLER                                               23, !2
         37      > JMPZ                                                     ~34, ->61
   22    38    >   DIV                                              ~35     !2, 24
         39        CAST                                          4  ~36     ~35
         40        ASSIGN                                                   !3, ~36
   23    41        MUL                                              ~38     !3, 24
         42        SUB                                              ~39     !2, ~38
         43        ASSIGN                                                   !2, ~39
   24    44        NOP                                                      
         45        FAST_CONCAT                                      ~41     !3, '+day'
         46        ASSIGN                                                   !4, ~41
   25    47        IS_SMALLER                                               1, !3
         48      > JMPZ                                                     ~43, ->50
   26    49    >   ASSIGN_OP                                     8          !4, 's'
   28    50    >   IS_SMALLER                                               !3, 3
         51      > JMPZ                                                     ~45, ->61
   29    52    >   IS_SMALLER                                               0, !2
         53      > JMPZ                                                     ~46, ->58
   30    54    >   ROPE_INIT                                     3  ~48     '%2C+'
         55        ROPE_ADD                                      1  ~48     ~48, !2
         56        ROPE_END                                      2  ~47     ~48, '+hr'
         57        ASSIGN_OP                                     8          !4, ~47
   32    58    >   IS_SMALLER                                               1, !2
         59      > JMPZ                                                     ~51, ->61
   33    60    >   ASSIGN_OP                                     8          !4, 's'
   37    61    > > RETURN                                                   !4
   38    62*     > RETURN                                                   null

End of function time_diff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.42 ms | 1407 KiB | 16 Q