3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (class_exists('DateTimeImmutable')) { function compareDate(DateTimeImmutable $d1, DateTimeImmutable $d2) { if ($d1 > $d2) { return 1; } if ($d2 > $d1) { return -1; } $utc = new DateTimeZone("UTC"); $d1micro = $d1->setTimeZone($utc)->format('u'); $d2micro = $d2->setTimeZone($utc)->format('u'); echo '$d1 micro = ', $d1micro, PHP_EOL; echo '$d2 micro = ', $d2micro, PHP_EOL; if ($d1micro > $d2micro) { return 1; } if ($d1micro < $d2micro) { return -1; } return 0; } $d1 = new DateTimeImmutable('2012-02-01 00:00:00.123456'); $d2 = new DateTimeImmutable('2012-02-01 00:00:00.023456'); var_dump(compareDate($d1, $d2)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/vt5cQ
function name:  (null)
number of ops:  21
compiled vars:  !0 = $d1, !1 = $d2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'class_exists'
          1        SEND_VAL                                                 'DateTimeImmutable'
          2        DO_ICALL                                         $2      
          3      > JMPZ                                                     $2, ->20
    5     4    >   DECLARE_FUNCTION                                         'comparedate'
   34     5        NEW                                              $3      'DateTimeImmutable'
          6        SEND_VAL_EX                                              '2012-02-01+00%3A00%3A00.123456'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $3
   35     9        NEW                                              $6      'DateTimeImmutable'
         10        SEND_VAL_EX                                              '2012-02-01+00%3A00%3A00.023456'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $6
   37    13        INIT_FCALL                                               'var_dump'
         14        INIT_FCALL_BY_NAME                                       'compareDate'
         15        SEND_VAR_EX                                              !0
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0  $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                                 
   38    20    > > RETURN                                                   1

Function %00comparedate%2Fin%2Fvt5cQ%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 35
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 38
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vt5cQ
function name:  compareDate
number of ops:  40
compiled vars:  !0 = $d1, !1 = $d2, !2 = $utc, !3 = $d1micro, !4 = $d2micro
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        IS_SMALLER                                               !1, !0
          3      > JMPZ                                                     ~5, ->5
    8     4    > > RETURN                                                   1
   11     5    >   IS_SMALLER                                               !0, !1
          6      > JMPZ                                                     ~6, ->8
   12     7    > > RETURN                                                   -1
   15     8    >   NEW                                              $7      'DateTimeZone'
          9        SEND_VAL_EX                                              'UTC'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $7
   17    12        INIT_METHOD_CALL                                         !0, 'setTimeZone'
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0  $10     
         15        INIT_METHOD_CALL                                         $10, 'format'
         16        SEND_VAL_EX                                              'u'
         17        DO_FCALL                                      0  $11     
         18        ASSIGN                                                   !3, $11
   18    19        INIT_METHOD_CALL                                         !1, 'setTimeZone'
         20        SEND_VAR_EX                                              !2
         21        DO_FCALL                                      0  $13     
         22        INIT_METHOD_CALL                                         $13, 'format'
         23        SEND_VAL_EX                                              'u'
         24        DO_FCALL                                      0  $14     
         25        ASSIGN                                                   !4, $14
   20    26        ECHO                                                     '%24d1+micro+%3D+'
         27        ECHO                                                     !3
         28        ECHO                                                     '%0A'
   21    29        ECHO                                                     '%24d2+micro+%3D+'
         30        ECHO                                                     !4
         31        ECHO                                                     '%0A'
   23    32        IS_SMALLER                                               !4, !3
         33      > JMPZ                                                     ~16, ->35
   24    34    > > RETURN                                                   1
   27    35    >   IS_SMALLER                                               !3, !4
         36      > JMPZ                                                     ~17, ->38
   28    37    > > RETURN                                                   -1
   31    38    > > RETURN                                                   0
   32    39*     > RETURN                                                   null

End of function %00comparedate%2Fin%2Fvt5cQ%3A5%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161 ms | 1400 KiB | 17 Q