3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo $phpdate = strtotime('now'); echo PHP_EOL; echo $mysqldate = date('Y-m-d H:i:s', $phpdate); function formatDate($time) { if ($time >= strtotime("today")) { return date("g:i A", $time); } elseif ($time >= strtotime("yesterday")) { return "Yesterday at " . date("g:i A", $time); } else { return date("M j, Y", $time); } } echo formatDate($phpdate); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RiUDD
function name:  (null)
number of ops:  17
compiled vars:  !0 = $phpdate, !1 = $mysqldate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'strtotime'
          1        SEND_VAL                                                 'now'
          2        DO_ICALL                                         $2      
          3        ASSIGN                                           ~3      !0, $2
          4        ECHO                                                     ~3
    5     5        ECHO                                                     '%0A'
    6     6        INIT_FCALL                                               'date'
          7        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $4      
         10        ASSIGN                                           ~5      !1, $4
         11        ECHO                                                     ~5
   19    12        INIT_FCALL                                               'formatdate'
         13        SEND_VAR                                                 !0
         14        DO_FCALL                                      0  $6      
         15        ECHO                                                     $6
   21    16      > RETURN                                                   1

Function formatdate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RiUDD
function name:  formatDate
number of ops:  30
compiled vars:  !0 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'strtotime'
          2        SEND_VAL                                                 'today'
          3        DO_ICALL                                         $1      
          4        IS_SMALLER_OR_EQUAL                                      $1, !0
          5      > JMPZ                                                     ~2, ->12
   11     6    >   INIT_FCALL                                               'date'
          7        SEND_VAL                                                 'g%3Ai+A'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $3      
         10      > RETURN                                                   $3
         11*       JMP                                                      ->29
   12    12    >   INIT_FCALL                                               'strtotime'
         13        SEND_VAL                                                 'yesterday'
         14        DO_ICALL                                         $4      
         15        IS_SMALLER_OR_EQUAL                                      $4, !0
         16      > JMPZ                                                     ~5, ->24
   13    17    >   INIT_FCALL                                               'date'
         18        SEND_VAL                                                 'g%3Ai+A'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $6      
         21        CONCAT                                           ~7      'Yesterday+at+', $6
         22      > RETURN                                                   ~7
         23*       JMP                                                      ->29
   15    24    >   INIT_FCALL                                               'date'
         25        SEND_VAL                                                 'M+j%2C+Y'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                         $8      
         28      > RETURN                                                   $8
   17    29*     > RETURN                                                   null

End of function formatdate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.84 ms | 1403 KiB | 18 Q