3v4l.org

run code in 300+ PHP versions simultaneously
<?php $period = getPeriod('2018-08-21 23:59:59.999999', '2018-08-22 00:00:00.000000'); print_r($period); function getPeriod($date1 = null, $date2 = null) { try { $dt_date1 = new \DateTime($date1); $dt_date2 = new \DateTime($date2); $diff = $dt_date2->diff($dt_date1); // Workaround für PHP Bug #75855 if ($diff->format('%f') < 0) { $diff->s--; //$diff->f++; // = $diff->f + 1; // = number_format($diff->f+1, 6, '.', ''); $diff->f = $diff->f + 1; // = number_format($diff->f+1, 6, '.', ''); } return $diff; } catch (\Exception $e) { $exceptionHanlder = new ExceptionHandler($e); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JJivD
function name:  (null)
number of ops:  9
compiled vars:  !0 = $period
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'getPeriod'
          1        SEND_VAL_EX                                              '2018-08-21+23%3A59%3A59.999999'
          2        SEND_VAL_EX                                              '2018-08-22+00%3A00%3A00.000000'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
    4     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   26     8      > RETURN                                                   1

Function getperiod:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Found catch point at position: 26
Branch analysis from position: 26
2 jumps found. (Code = 107) Position 1 = 27, Position 2 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JJivD
function name:  getPeriod
number of ops:  32
compiled vars:  !0 = $date1, !1 = $date2, !2 = $dt_date1, !3 = $dt_date2, !4 = $diff, !5 = $e, !6 = $exceptionHanlder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
    9     2        NEW                                              $7      'DateTime'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $7
   10     6        NEW                                              $10     'DateTime'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !3, $10
   11    10        INIT_METHOD_CALL                                         !3, 'diff'
         11        SEND_VAR_EX                                              !2
         12        DO_FCALL                                      0  $13     
         13        ASSIGN                                                   !4, $13
   14    14        INIT_METHOD_CALL                                         !4, 'format'
         15        SEND_VAL_EX                                              '%25f'
         16        DO_FCALL                                      0  $15     
         17        IS_SMALLER                                               $15, 0
         18      > JMPZ                                                     ~16, ->24
   15    19    >   PRE_DEC_OBJ                                              !4, 's'
   17    20        FETCH_OBJ_R                                      ~19     !4, 'f'
         21        ADD                                              ~20     ~19, 1
         22        ASSIGN_OBJ                                               !4, 'f'
         23        OP_DATA                                                  ~20
   20    24    > > RETURN                                                   !4
         25*       JMP                                                      ->31
   22    26  E > > CATCH                                       last         'Exception'
   23    27    >   NEW                                              $21     'ExceptionHandler'
         28        SEND_VAR_EX                                              !5
         29        DO_FCALL                                      0          
         30        ASSIGN                                                   !6, $21
   26    31      > RETURN                                                   null

End of function getperiod

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.76 ms | 1400 KiB | 15 Q