3v4l.org

run code in 300+ PHP versions simultaneously
<?php $begin_time = strtotime("09:15"); $end_time = strtotime("14:00"); $end_date = new DateTime(date("Y-m-d H:i:s", $end_time)); $begin_date = new DateTime(date("Y-m-d H:i:s", $begin_time)); echo "begin_date is " . $begin_date->format('Y-m-d H:i:s') . " and end_date is " . $end_date->format('Y-m-d H:i:s') . "<br>"; $diff = $end_date->diff($begin_date); $diff_in_hours = $diff->h + $diff->i / 60; echo "The difference is " . $diff->h . " hours and " . $diff->i . " minutes, which is " . $diff_in_hours . " hours<br>";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EQHoX
function name:  (null)
number of ops:  54
compiled vars:  !0 = $begin_time, !1 = $end_time, !2 = $end_date, !3 = $begin_date, !4 = $diff, !5 = $diff_in_hours
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'strtotime'
          1        SEND_VAL                                                 '09%3A15'
          2        DO_ICALL                                         $6      
          3        ASSIGN                                                   !0, $6
    4     4        INIT_FCALL                                               'strtotime'
          5        SEND_VAL                                                 '14%3A00'
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !1, $8
    6     8        NEW                                              $10     'DateTime'
          9        INIT_FCALL                                               'date'
         10        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $11     
         13        SEND_VAR_NO_REF_EX                                       $11
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !2, $10
    7    16        NEW                                              $14     'DateTime'
         17        INIT_FCALL                                               'date'
         18        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $15     
         21        SEND_VAR_NO_REF_EX                                       $15
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !3, $14
    9    24        INIT_METHOD_CALL                                         !3, 'format'
         25        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As'
         26        DO_FCALL                                      0  $18     
         27        CONCAT                                           ~19     'begin_date+is+', $18
         28        CONCAT                                           ~20     ~19, '+and+end_date+is+'
         29        INIT_METHOD_CALL                                         !2, 'format'
         30        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As'
         31        DO_FCALL                                      0  $21     
         32        CONCAT                                           ~22     ~20, $21
         33        CONCAT                                           ~23     ~22, '%3Cbr%3E'
         34        ECHO                                                     ~23
   11    35        INIT_METHOD_CALL                                         !2, 'diff'
         36        SEND_VAR_EX                                              !3
         37        DO_FCALL                                      0  $24     
         38        ASSIGN                                                   !4, $24
   12    39        FETCH_OBJ_R                                      ~26     !4, 'h'
         40        FETCH_OBJ_R                                      ~27     !4, 'i'
         41        DIV                                              ~28     ~27, 60
         42        ADD                                              ~29     ~26, ~28
         43        ASSIGN                                                   !5, ~29
   13    44        FETCH_OBJ_R                                      ~31     !4, 'h'
         45        CONCAT                                           ~32     'The+difference+is+', ~31
         46        CONCAT                                           ~33     ~32, '+hours+and+'
         47        FETCH_OBJ_R                                      ~34     !4, 'i'
         48        CONCAT                                           ~35     ~33, ~34
         49        CONCAT                                           ~36     ~35, '+minutes%2C+which+is+'
         50        CONCAT                                           ~37     ~36, !5
         51        CONCAT                                           ~38     ~37, '+hours%3Cbr%3E'
         52        ECHO                                                     ~38
         53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.08 ms | 1400 KiB | 17 Q