3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertToTimestamp($dateStr) { $dateStr = trim($dateStr); var_dump( function_exists("date_create") ); if (!function_exists('date_create')) { return strtotime($dateStr); } $oDate = date_create($dateStr); if ($oDate instanceof DateTime) { #$curErrors = $oDate->getLastErrors(); #print_r($curErrors); #$curErrors = array_filter($curErrors, 'is_numeric'); #$curErrors = (bool)array_sum($curErrors); #if (!$curErrors) { return (int)$oDate->format('U'); #} } return false; } echo convertToTimestamp("2012-01-01"); // 1325376000 echo "<br>"; var_dump( convertToTimestamp("foo") ); // sollte false
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7s2nX
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'converttotimestamp'
          1        SEND_VAL                                                 '2012-01-01'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   27     4        ECHO                                                     '%3Cbr%3E'
   28     5        INIT_FCALL                                               'var_dump'
          6        INIT_FCALL                                               'converttotimestamp'
          7        SEND_VAL                                                 'foo'
          8        DO_FCALL                                      0  $1      
          9        SEND_VAR                                                 $1
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function converttotimestamp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7s2nX
function name:  convertToTimestamp
number of ops:  33
compiled vars:  !0 = $dateStr, !1 = $oDate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'trim'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
    6     5        INIT_FCALL                                               'var_dump'
          6        INIT_FCALL                                               'function_exists'
          7        SEND_VAL                                                 'date_create'
          8        DO_ICALL                                         $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                                 
    8    11        INIT_FCALL                                               'function_exists'
         12        SEND_VAL                                                 'date_create'
         13        DO_ICALL                                         $6      
         14        BOOL_NOT                                         ~7      $6
         15      > JMPZ                                                     ~7, ->20
    9    16    >   INIT_FCALL                                               'strtotime'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $8      
         19      > RETURN                                                   $8
   12    20    >   INIT_FCALL                                               'date_create'
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $9      
         23        ASSIGN                                                   !1, $9
   13    24        INSTANCEOF                                               !1, 'DateTime'
         25      > JMPZ                                                     ~11, ->31
   19    26    >   INIT_METHOD_CALL                                         !1, 'format'
         27        SEND_VAL_EX                                              'U'
         28        DO_FCALL                                      0  $12     
         29        CAST                                          4  ~13     $12
         30      > RETURN                                                   ~13
   22    31    > > RETURN                                                   <false>
   23    32*     > RETURN                                                   null

End of function converttotimestamp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.71 ms | 1394 KiB | 25 Q