3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ago($when) { $diff = $when; // Days $day = floor($diff / 86400); $diff = $diff - ($day * 86400); // Hours $hrs = floor($diff / 3600); $diff = $diff - ($hrs * 3600); // Mins $min = floor($diff / 60); $diff = $diff - ($min * 60); // Secs $sec = $diff; // Return how long ago this was. eg: 3d 17h 4m 18s ago // Skips left fields if they aren't necessary, eg. 16h 0m 27s ago / 10m 7s ago $str = sprintf("%s%s%s%s", $day != 0 ? $day."d " : "", ($day != 0 || $hrs != 0) ? $hrs."h " : "", ($day != 0 || $hrs != 0 || $min != 0) ? $min."m " : "", $sec."s ago" ); return $str; } echo ago(3600);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RHW1k
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'ago'
          1        SEND_VAL                                                 3600
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function ago:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 34
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 47) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 44
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 47) Position 1 = 48, Position 2 = 50
Branch analysis from position: 48
2 jumps found. (Code = 47) Position 1 = 51, Position 2 = 53
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 57
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
Branch analysis from position: 50
Branch analysis from position: 44
2 jumps found. (Code = 47) Position 1 = 48, Position 2 = 50
Branch analysis from position: 48
Branch analysis from position: 50
Branch analysis from position: 40
Branch analysis from position: 34
2 jumps found. (Code = 47) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
Branch analysis from position: 40
filename:       /in/RHW1k
function name:  ago
number of ops:  65
compiled vars:  !0 = $when, !1 = $diff, !2 = $day, !3 = $hrs, !4 = $min, !5 = $sec, !6 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, !0
    7     2        INIT_FCALL                                               'floor'
          3        DIV                                              ~8      !1, 86400
          4        SEND_VAL                                                 ~8
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !2, $9
    8     7        MUL                                              ~11     !2, 86400
          8        SUB                                              ~12     !1, ~11
          9        ASSIGN                                                   !1, ~12
   11    10        INIT_FCALL                                               'floor'
         11        DIV                                              ~14     !1, 3600
         12        SEND_VAL                                                 ~14
         13        DO_ICALL                                         $15     
         14        ASSIGN                                                   !3, $15
   12    15        MUL                                              ~17     !3, 3600
         16        SUB                                              ~18     !1, ~17
         17        ASSIGN                                                   !1, ~18
   15    18        INIT_FCALL                                               'floor'
         19        DIV                                              ~20     !1, 60
         20        SEND_VAL                                                 ~20
         21        DO_ICALL                                         $21     
         22        ASSIGN                                                   !4, $21
   16    23        MUL                                              ~23     !4, 60
         24        SUB                                              ~24     !1, ~23
         25        ASSIGN                                                   !1, ~24
   19    26        ASSIGN                                                   !5, !1
   23    27        INIT_FCALL                                               'sprintf'
         28        SEND_VAL                                                 '%25s%25s%25s%25s'
   24    29        IS_NOT_EQUAL                                             !2, 0
         30      > JMPZ                                                     ~27, ->34
         31    >   CONCAT                                           ~28     !2, 'd+'
         32        QM_ASSIGN                                        ~29     ~28
         33      > JMP                                                      ->35
         34    >   QM_ASSIGN                                        ~29     ''
         35    >   SEND_VAL                                                 ~29
   25    36        IS_NOT_EQUAL                                     ~30     !2, 0
         37      > JMPNZ_EX                                         ~30     ~30, ->40
         38    >   IS_NOT_EQUAL                                     ~31     !3, 0
         39        BOOL                                             ~30     ~31
         40    > > JMPZ                                                     ~30, ->44
         41    >   CONCAT                                           ~32     !3, 'h+'
         42        QM_ASSIGN                                        ~33     ~32
         43      > JMP                                                      ->45
         44    >   QM_ASSIGN                                        ~33     ''
         45    >   SEND_VAL                                                 ~33
   26    46        IS_NOT_EQUAL                                     ~34     !2, 0
         47      > JMPNZ_EX                                         ~34     ~34, ->50
         48    >   IS_NOT_EQUAL                                     ~35     !3, 0
         49        BOOL                                             ~34     ~35
         50    > > JMPNZ_EX                                         ~34     ~34, ->53
         51    >   IS_NOT_EQUAL                                     ~36     !4, 0
         52        BOOL                                             ~34     ~36
         53    > > JMPZ                                                     ~34, ->57
         54    >   CONCAT                                           ~37     !4, 'm+'
         55        QM_ASSIGN                                        ~38     ~37
         56      > JMP                                                      ->58
         57    >   QM_ASSIGN                                        ~38     ''
         58    >   SEND_VAL                                                 ~38
   27    59        CONCAT                                           ~39     !5, 's+ago'
         60        SEND_VAL                                                 ~39
         61        DO_ICALL                                         $40     
   23    62        ASSIGN                                                   !6, $40
   30    63      > RETURN                                                   !6
   31    64*     > RETURN                                                   null

End of function ago

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.65 ms | 1407 KiB | 18 Q