3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo $phpdate = strtotime('0 day'); echo PHP_EOL; function relative_date($time) { $today = strtotime(date('M j, Y')); $reldays = ($time - $today)/86400; if ($reldays >= 0 && $reldays < 1) { return 'Today'; } else if ($reldays >= -1 && $reldays < 0) { return 'Yesterday'; } else { return date('l, j F, Y',$time ? $time : time()); } } $my_timestamp = "2007-12-15 11:22:47"; //store the results of the function into $my_relative_time $my_relative_time = relative_date(strtotime($my_timestamp )); //output var_dump($my_relative_time); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FlX7V
function name:  (null)
number of ops:  18
compiled vars:  !0 = $phpdate, !1 = $my_timestamp, !2 = $my_relative_time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'strtotime'
          1        SEND_VAL                                                 '0+day'
          2        DO_ICALL                                         $3      
          3        ASSIGN                                           ~4      !0, $3
          4        ECHO                                                     ~4
    5     5        ECHO                                                     '%0A'
   30     6        ASSIGN                                                   !1, '2007-12-15+11%3A22%3A47'
   35     7        INIT_FCALL                                               'relative_date'
          8        INIT_FCALL                                               'strtotime'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $6      
         11        SEND_VAR                                                 $6
         12        DO_FCALL                                      0  $7      
         13        ASSIGN                                                   !2, $7
   40    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                                 
   44    17      > RETURN                                                   1

Function relative_date:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 15
filename:       /in/FlX7V
function name:  relative_date
number of ops:  37
compiled vars:  !0 = $time, !1 = $today, !2 = $reldays
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'strtotime'
          2        INIT_FCALL                                               'date'
          3        SEND_VAL                                                 'M+j%2C+Y'
          4        DO_ICALL                                         $3      
          5        SEND_VAR                                                 $3
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !1, $4
   11     8        SUB                                              ~6      !0, !1
          9        DIV                                              ~7      ~6, 86400
         10        ASSIGN                                                   !2, ~7
   13    11        IS_SMALLER_OR_EQUAL                              ~9      0, !2
         12      > JMPZ_EX                                          ~9      ~9, ->15
         13    >   IS_SMALLER                                       ~10     !2, 1
         14        BOOL                                             ~9      ~10
         15    > > JMPZ                                                     ~9, ->18
   15    16    > > RETURN                                                   'Today'
         17*       JMP                                                      ->36
   17    18    >   IS_SMALLER_OR_EQUAL                              ~11     -1, !2
         19      > JMPZ_EX                                          ~11     ~11, ->22
         20    >   IS_SMALLER                                       ~12     !2, 0
         21        BOOL                                             ~11     ~12
         22    > > JMPZ                                                     ~11, ->25
   19    23    > > RETURN                                                   'Yesterday'
         24*       JMP                                                      ->36
   25    25    >   INIT_FCALL                                               'date'
         26        SEND_VAL                                                 'l%2C+j+F%2C+Y'
         27      > JMPZ                                                     !0, ->30
         28    >   QM_ASSIGN                                        ~13     !0
         29      > JMP                                                      ->33
         30    >   INIT_FCALL                                               'time'
         31        DO_ICALL                                         $14     
         32        QM_ASSIGN                                        ~13     $14
         33    >   SEND_VAL                                                 ~13
         34        DO_ICALL                                         $15     
         35      > RETURN                                                   $15
   27    36*     > RETURN                                                   null

End of function relative_date

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.63 ms | 1403 KiB | 22 Q