3v4l.org

run code in 500+ PHP versions simultaneously
<?php function dateIntervalToSeconds($dateInterval) { $reference = new DateTimeImmutable; $endTime = $reference->add($dateInterval); return $endTime->getTimestamp() - $reference->getTimestamp(); } $duration = '1h1m1s'; $interval = new DateInterval('PT' . strtoupper($duration)); echo $duration, ' is ', dateIntervalToSeconds($interval), ' seconds';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UaEYB
function name:  (null)
number of ops:  17
compiled vars:  !0 = $duration, !1 = $interval
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                       !0, '1h1m1s'
   13     1        NEW                                                  $3      'DateInterval'
          2        INIT_FCALL                                                   'strtoupper'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $4      
          5        CONCAT                                               ~5      'PT', $4
          6        SEND_VAL_EX                                                  ~5
          7        DO_FCALL                                          0          
          8        ASSIGN                                                       !1, $3
   15     9        ECHO                                                         !0
         10        ECHO                                                         '+is+'
         11        INIT_FCALL                                                   'dateintervaltoseconds'
         12        SEND_VAR                                                     !1
         13        DO_FCALL                                          0  $8      
         14        ECHO                                                         $8
         15        ECHO                                                         '+seconds'
         16      > RETURN                                                       1

Function dateintervaltoseconds:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UaEYB
function name:  dateIntervalToSeconds
number of ops:  15
compiled vars:  !0 = $dateInterval, !1 = $reference, !2 = $endTime
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        NEW                                                  $3      'DateTimeImmutable'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $3
    6     4        INIT_METHOD_CALL                                             !1, 'add'
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0  $6      
          7        ASSIGN                                                       !2, $6
    8     8        INIT_METHOD_CALL                                             !2, 'getTimestamp'
          9        DO_FCALL                                          0  $8      
         10        INIT_METHOD_CALL                                             !1, 'getTimestamp'
         11        DO_FCALL                                          0  $9      
         12        SUB                                                  ~10     $8, $9
         13      > RETURN                                                       ~10
    9    14*     > RETURN                                                       null

End of function dateintervaltoseconds

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.4 ms | 2581 KiB | 15 Q