3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dateWord($from, $now) { $timezone = new DateTimeZone('Asia/Shanghai'); $now = new DateTime($now, $timezone); $from = new DateTime($from, $timezone); $between = $now->diff($from); if(!$between->invert) return false; /** 如果超过了一年 **/ if($between->y) return $from->format('Y年m月d日'); /** 一年内大于七天 **/ if($between->days > 6) return $from->format('n月j日'); /** 一个礼拜内但是大于两天**/ if($between->days > 1) return $between->format('%d天前'); /** 如果是昨天 **/ if($between->days) return $from->format('昨天 H:i'); /** 如果一天之内超过一个小时 **/ if($between->h > 1) return $between->format('%h小时前'); if($between->i > 1) return $between->format('%i分钟前'); return $between->s ? $between->format('%s秒前') : '刚刚'; } function dateWordToHtml($from, $now = 'now') { echo $dateWord = dateWord($from, $now); $from = new DateTime($from, new DateTimeZone('Asia/Shanghai')); $fromWord = $from->format('Y年m月d日 H:i'); return "<span title=\"$fromWord\">$dateWord</span>"; } //dateWord()函数对应的是Typecho原版的返回,dateWordToHtml()函数则是对应你修改的那个函数 echo dateWordToHtml("2014/4/14 9:32");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oXICA
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   INIT_FCALL                                               'datewordtohtml'
          1        SEND_VAL                                                 '2014%2F4%2F14+9%3A32'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function dateword:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 30
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 37
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 44
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 50
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 57
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 64
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 71
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oXICA
function name:  dateWord
number of ops:  74
compiled vars:  !0 = $from, !1 = $now, !2 = $timezone, !3 = $between
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        NEW                                              $4      'DateTimeZone'
          3        SEND_VAL_EX                                              'Asia%2FShanghai'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $4
    4     6        NEW                                              $7      'DateTime'
          7        SEND_VAR_EX                                              !1
          8        SEND_VAR_EX                                              !2
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $7
    5    11        NEW                                              $10     'DateTime'
         12        SEND_VAR_EX                                              !0
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !0, $10
    6    16        INIT_METHOD_CALL                                         !1, 'diff'
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0  $13     
         19        ASSIGN                                                   !3, $13
    8    20        FETCH_OBJ_R                                      ~15     !3, 'invert'
         21        BOOL_NOT                                         ~16     ~15
         22      > JMPZ                                                     ~16, ->24
         23    > > RETURN                                                   <false>
   11    24    >   FETCH_OBJ_R                                      ~17     !3, 'y'
         25      > JMPZ                                                     ~17, ->30
   12    26    >   INIT_METHOD_CALL                                         !0, 'format'
         27        SEND_VAL_EX                                              'Y%E5%B9%B4m%E6%9C%88d%E6%97%A5'
         28        DO_FCALL                                      0  $18     
         29      > RETURN                                                   $18
   15    30    >   FETCH_OBJ_R                                      ~19     !3, 'days'
         31        IS_SMALLER                                               6, ~19
         32      > JMPZ                                                     ~20, ->37
   16    33    >   INIT_METHOD_CALL                                         !0, 'format'
         34        SEND_VAL_EX                                              'n%E6%9C%88j%E6%97%A5'
         35        DO_FCALL                                      0  $21     
         36      > RETURN                                                   $21
   19    37    >   FETCH_OBJ_R                                      ~22     !3, 'days'
         38        IS_SMALLER                                               1, ~22
         39      > JMPZ                                                     ~23, ->44
   20    40    >   INIT_METHOD_CALL                                         !3, 'format'
         41        SEND_VAL_EX                                              '%25d%E5%A4%A9%E5%89%8D'
         42        DO_FCALL                                      0  $24     
         43      > RETURN                                                   $24
   23    44    >   FETCH_OBJ_R                                      ~25     !3, 'days'
         45      > JMPZ                                                     ~25, ->50
   24    46    >   INIT_METHOD_CALL                                         !0, 'format'
         47        SEND_VAL_EX                                              '%E6%98%A8%E5%A4%A9+H%3Ai'
         48        DO_FCALL                                      0  $26     
         49      > RETURN                                                   $26
   27    50    >   FETCH_OBJ_R                                      ~27     !3, 'h'
         51        IS_SMALLER                                               1, ~27
         52      > JMPZ                                                     ~28, ->57
   28    53    >   INIT_METHOD_CALL                                         !3, 'format'
         54        SEND_VAL_EX                                              '%25h%E5%B0%8F%E6%97%B6%E5%89%8D'
         55        DO_FCALL                                      0  $29     
         56      > RETURN                                                   $29
   30    57    >   FETCH_OBJ_R                                      ~30     !3, 'i'
         58        IS_SMALLER                                               1, ~30
         59      > JMPZ                                                     ~31, ->64
   31    60    >   INIT_METHOD_CALL                                         !3, 'format'
         61        SEND_VAL_EX                                              '%25i%E5%88%86%E9%92%9F%E5%89%8D'
         62        DO_FCALL                                      0  $32     
         63      > RETURN                                                   $32
   33    64    >   FETCH_OBJ_R                                      ~33     !3, 's'
         65      > JMPZ                                                     ~33, ->71
         66    >   INIT_METHOD_CALL                                         !3, 'format'
         67        SEND_VAL_EX                                              '%25s%E7%A7%92%E5%89%8D'
         68        DO_FCALL                                      0  $34     
         69        QM_ASSIGN                                        ~35     $34
         70      > JMP                                                      ->72
         71    >   QM_ASSIGN                                        ~35     '%E5%88%9A%E5%88%9A'
         72    > > RETURN                                                   ~35
   34    73*     > RETURN                                                   null

End of function dateword

Function datewordtohtml:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oXICA
function name:  dateWordToHtml
number of ops:  27
compiled vars:  !0 = $from, !1 = $now, !2 = $dateWord, !3 = $fromWord
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'now'
   37     2        INIT_FCALL                                               'dateword'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $4      
          6        ASSIGN                                           ~5      !2, $4
          7        ECHO                                                     ~5
   38     8        NEW                                              $6      'DateTime'
          9        SEND_VAR_EX                                              !0
         10        NEW                                              $7      'DateTimeZone'
         11        SEND_VAL_EX                                              'Asia%2FShanghai'
         12        DO_FCALL                                      0          
         13        SEND_VAR_NO_REF_EX                                       $7
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !0, $6
   39    16        INIT_METHOD_CALL                                         !0, 'format'
         17        SEND_VAL_EX                                              'Y%E5%B9%B4m%E6%9C%88d%E6%97%A5+H%3Ai'
         18        DO_FCALL                                      0  $11     
         19        ASSIGN                                                   !3, $11
   40    20        ROPE_INIT                                     5  ~14     '%3Cspan+title%3D%22'
         21        ROPE_ADD                                      1  ~14     ~14, !3
         22        ROPE_ADD                                      2  ~14     ~14, '%22%3E'
         23        ROPE_ADD                                      3  ~14     ~14, !2
         24        ROPE_END                                      4  ~13     ~14, '%3C%2Fspan%3E'
         25      > RETURN                                                   ~13
   41    26*     > RETURN                                                   null

End of function datewordtohtml

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.94 ms | 1406 KiB | 15 Q