3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( array(new DateTime(), new DateTime('2013-12-31')), array(new DateTime('2013-10-28'), new DateTime('2013-12-31')), ); foreach($data as $parameters) { var_dump(call_user_func_array('getDateDifferenceAsDays', $parameters)); var_dump(call_user_func_array('getDateDifferenceAsDays2', $parameters)); } function getDateDifferenceAsDays(\DateTime $dateStart, \DateTime $dateEnd) { $refDateStart = new \DateTime($dateStart->format('Y-m-d')); $refDateEnd = new \DateTime($dateEnd->format('Y-m-d')); $interval = $refDateStart->diff($refDateEnd); return (int)$interval->format('%R%a'); } function getDateDifferenceAsDays2(\DateTime $dateStart, \DateTime $dateEnd) { $refDateStart = clone $dateStart; $refDateEnd = clone $dateEnd; $interval = $refDateStart->diff($refDateEnd); return (int)$interval->format('%R%a'); } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 35
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 35
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/QmFSt
function name:  (null)
number of ops:  37
compiled vars:  !0 = $data, !1 = $parameters
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   NEW                                              $2      'DateTime'
          1        DO_FCALL                                      0          
          2        INIT_ARRAY                                       ~4      $2
          3        NEW                                              $5      'DateTime'
          4        SEND_VAL_EX                                              '2013-12-31'
          5        DO_FCALL                                      0          
          6        ADD_ARRAY_ELEMENT                                ~4      $5
          7        INIT_ARRAY                                       ~7      ~4
    5     8        NEW                                              $8      'DateTime'
          9        SEND_VAL_EX                                              '2013-10-28'
         10        DO_FCALL                                      0          
         11        INIT_ARRAY                                       ~10     $8
         12        NEW                                              $11     'DateTime'
         13        SEND_VAL_EX                                              '2013-12-31'
         14        DO_FCALL                                      0          
         15        ADD_ARRAY_ELEMENT                                ~10     $11
         16        ADD_ARRAY_ELEMENT                                ~7      ~10
    3    17        ASSIGN                                                   !0, ~7
    8    18      > FE_RESET_R                                       $14     !0, ->35
         19    > > FE_FETCH_R                                               $14, !1, ->35
    9    20    >   INIT_FCALL                                               'var_dump'
         21        INIT_USER_CALL                                0          'call_user_func_array', 'getDateDifferenceAsDays'
         22        SEND_ARRAY                                               !1
         23        CHECK_UNDEF_ARGS                                         
         24        DO_FCALL                                      0  $15     
         25        SEND_VAR                                                 $15
         26        DO_ICALL                                                 
   10    27        INIT_FCALL                                               'var_dump'
         28        INIT_USER_CALL                                0          'call_user_func_array', 'getDateDifferenceAsDays2'
         29        SEND_ARRAY                                               !1
         30        CHECK_UNDEF_ARGS                                         
         31        DO_FCALL                                      0  $17     
         32        SEND_VAR                                                 $17
         33        DO_ICALL                                                 
    8    34      > JMP                                                      ->19
         35    >   FE_FREE                                                  $14
   33    36      > RETURN                                                   1

Function getdatedifferenceasdays:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QmFSt
function name:  getDateDifferenceAsDays
number of ops:  26
compiled vars:  !0 = $dateStart, !1 = $dateEnd, !2 = $refDateStart, !3 = $refDateEnd, !4 = $interval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        NEW                                              $5      'DateTime'
          3        INIT_METHOD_CALL                                         !0, 'format'
          4        SEND_VAL_EX                                              'Y-m-d'
          5        DO_FCALL                                      0  $6      
          6        SEND_VAR_NO_REF_EX                                       $6
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $5
   17     9        NEW                                              $9      'DateTime'
         10        INIT_METHOD_CALL                                         !1, 'format'
         11        SEND_VAL_EX                                              'Y-m-d'
         12        DO_FCALL                                      0  $10     
         13        SEND_VAR_NO_REF_EX                                       $10
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !3, $9
   19    16        INIT_METHOD_CALL                                         !2, 'diff'
         17        SEND_VAR_EX                                              !3
         18        DO_FCALL                                      0  $13     
         19        ASSIGN                                                   !4, $13
   21    20        INIT_METHOD_CALL                                         !4, 'format'
         21        SEND_VAL_EX                                              '%25R%25a'
         22        DO_FCALL                                      0  $15     
         23        CAST                                          4  ~16     $15
         24      > RETURN                                                   ~16
   22    25*     > RETURN                                                   null

End of function getdatedifferenceasdays

Function getdatedifferenceasdays2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QmFSt
function name:  getDateDifferenceAsDays2
number of ops:  16
compiled vars:  !0 = $dateStart, !1 = $dateEnd, !2 = $refDateStart, !3 = $refDateEnd, !4 = $interval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        CLONE                                            ~5      !0
          3        ASSIGN                                                   !2, ~5
   27     4        CLONE                                            ~7      !1
          5        ASSIGN                                                   !3, ~7
   29     6        INIT_METHOD_CALL                                         !2, 'diff'
          7        SEND_VAR_EX                                              !3
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                                   !4, $9
   31    10        INIT_METHOD_CALL                                         !4, 'format'
         11        SEND_VAL_EX                                              '%25R%25a'
         12        DO_FCALL                                      0  $11     
         13        CAST                                          4  ~12     $11
         14      > RETURN                                                   ~12
   32    15*     > RETURN                                                   null

End of function getdatedifferenceasdays2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.02 ms | 1404 KiB | 15 Q