3v4l.org

run code in 300+ PHP versions simultaneously
<?php $then = "2013-03-03 16:02:00"; $now = time(); $diff = $now - $then; function timeago($time) { $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade"); $lengths = array("60","60","24","7","4.35","12","10"); $now = time(); $difference = $now - $time; $tense = "ago"; for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { $difference /= $lengths[$j]; } $difference = round($difference); if($difference != 1) { $periods[$j].= "s"; } return "$difference $periods[$j] $tense"; } echo timeago($diff); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pkn3K
function name:  (null)
number of ops:  11
compiled vars:  !0 = $then, !1 = $now, !2 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '2013-03-03+16%3A02%3A00'
    3     1        INIT_FCALL                                               'time'
          2        DO_ICALL                                         $4      
          3        ASSIGN                                                   !1, $4
    5     4        SUB                                              ~6      !1, !0
          5        ASSIGN                                                   !2, ~6
   32     6        INIT_FCALL                                               'timeago'
          7        SEND_VAR                                                 !2
          8        DO_FCALL                                      0  $8      
          9        ECHO                                                     $8
         10      > RETURN                                                   1

Function timeago:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 11
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
Branch analysis from position: 21
Branch analysis from position: 21
filename:       /in/pkn3K
function name:  timeago
number of ops:  38
compiled vars:  !0 = $time, !1 = $periods, !2 = $lengths, !3 = $now, !4 = $difference, !5 = $tense, !6 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN                                                   !1, <array>
   10     2        ASSIGN                                                   !2, <array>
   12     3        INIT_FCALL                                               'time'
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !3, $9
   14     6        SUB                                              ~11     !3, !0
          7        ASSIGN                                                   !4, ~11
   15     8        ASSIGN                                                   !5, 'ago'
   17     9        ASSIGN                                                   !6, 0
         10      > JMP                                                      ->14
   19    11    >   FETCH_DIM_R                                      ~15     !2, !6
         12        ASSIGN_OP                                     4          !4, ~15
   17    13        PRE_INC                                                  !6
         14    >   FETCH_DIM_R                                      ~18     !2, !6
         15        IS_SMALLER_OR_EQUAL                              ~19     ~18, !4
         16      > JMPZ_EX                                          ~19     ~19, ->21
         17    >   COUNT                                            ~20     !2
         18        SUB                                              ~21     ~20, 1
         19        IS_SMALLER                                       ~22     !6, ~21
         20        BOOL                                             ~19     ~22
         21    > > JMPNZ                                                    ~19, ->11
   22    22    >   INIT_FCALL                                               'round'
         23        SEND_VAR                                                 !4
         24        DO_ICALL                                         $23     
         25        ASSIGN                                                   !4, $23
   24    26        IS_NOT_EQUAL                                             !4, 1
         27      > JMPZ                                                     ~25, ->30
   26    28    >   ASSIGN_DIM_OP                .=               8          !1, !6
         29        OP_DATA                                                  's'
   29    30    >   ROPE_INIT                                     5  ~29     !4
         31        ROPE_ADD                                      1  ~29     ~29, '+'
         32        FETCH_DIM_R                                      ~27     !1, !6
         33        ROPE_ADD                                      2  ~29     ~29, ~27
         34        ROPE_ADD                                      3  ~29     ~29, '+'
         35        ROPE_END                                      4  ~28     ~29, !5
         36      > RETURN                                                   ~28
   30    37*     > RETURN                                                   null

End of function timeago

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.54 ms | 1403 KiB | 18 Q