3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertToTimestamp($str) { $str = trim($str); if (!function_exists('date_create')) { echo "strtotime"; $ts = strtotime($str); // Doku: Vor PHP 5.1.0 gab die Funktion -1 im Fehlerfall zurück. if ($ts === -1) $ts = false; return $ts; } echo "date_create"; $date = date_create($str); if ($date != false) { return (int)date_format($date, 'U'); } return false; } var_dump( convertToTimestamp("2011-03-01") ); // 1298937600 var_dump( convertToTimestamp("2011-02-29") ); // 1298937600 var_dump( convertToTimestamp("foo") ); // false
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tMbhb
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'converttotimestamp'
          2        SEND_VAL                                                 '2011-03-01'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   25     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'converttotimestamp'
          8        SEND_VAL                                                 '2011-02-29'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   26    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'converttotimestamp'
         14        SEND_VAL                                                 'foo'
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

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

End of function converttotimestamp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
418.24 ms | 1403 KiB | 30 Q