3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); date_default_timezone_set('Europe/Berlin'); function convertToTimestamp($str) { echo "Input: " . $str . "<br>"; $str = trim($str); // date_create(), date_fromat() ab PHP 5.2.0 if (function_exists('date_create') && function_exists('date_format')) { $date = date_create($str); $x = ($date !== false) ? (int)date_format($date, 'U') : false; echo "date_create()"; var_dump( $x ); echo "Entspricht: " . date("Y-m-d H:i", $x); echo "<p><hr></p>"; return; } // Fallback mit strtotime() $ts = strtotime($str); if ($ts == -1) $ts = false; // vor PHP 5.1 kommt -1 bei Fehler echo "strtotoime()"; var_dump($ts); echo "Entspricht: " . date("Y-m-d H:i", $ts); echo "<p><hr></p>\n"; } convertToTimestamp("2012-01-01"); convertToTimestamp("2012-01-01 15:00"); convertToTimestamp("2011-02-29"); convertToTimestamp("foo"); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0gVml
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 -1
          2        DO_ICALL                                                 
    4     3        INIT_FCALL                                               'date_default_timezone_set'
          4        SEND_VAL                                                 'Europe%2FBerlin'
          5        DO_ICALL                                                 
   31     6        INIT_FCALL                                               'converttotimestamp'
          7        SEND_VAL                                                 '2012-01-01'
          8        DO_FCALL                                      0          
   32     9        INIT_FCALL                                               'converttotimestamp'
         10        SEND_VAL                                                 '2012-01-01+15%3A00'
         11        DO_FCALL                                      0          
   33    12        INIT_FCALL                                               'converttotimestamp'
         13        SEND_VAL                                                 '2011-02-29'
         14        DO_FCALL                                      0          
   34    15        INIT_FCALL                                               'converttotimestamp'
         16        SEND_VAL                                                 'foo'
         17        DO_FCALL                                      0          
   35    18      > RETURN                                                   1

Function converttotimestamp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 44
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 30
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 51
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
Branch analysis from position: 16
filename:       /in/0gVml
function name:  convertToTimestamp
number of ops:  63
compiled vars:  !0 = $str, !1 = $date, !2 = $x, !3 = $ts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        CONCAT                                           ~4      'Input%3A+', !0
          2        CONCAT                                           ~5      ~4, '%3Cbr%3E'
          3        ECHO                                                     ~5
    9     4        INIT_FCALL                                               'trim'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !0, $6
   12     8        INIT_FCALL                                               'function_exists'
          9        SEND_VAL                                                 'date_create'
         10        DO_ICALL                                         $8      
         11      > JMPZ_EX                                          ~9      $8, ->16
         12    >   INIT_FCALL                                               'function_exists'
         13        SEND_VAL                                                 'date_format'
         14        DO_ICALL                                         $10     
         15        BOOL                                             ~9      $10
         16    > > JMPZ                                                     ~9, ->44
   13    17    >   INIT_FCALL                                               'date_create'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $11     
         20        ASSIGN                                                   !1, $11
   14    21        TYPE_CHECK                                  1018          !1
         22      > JMPZ                                                     ~13, ->30
         23    >   INIT_FCALL                                               'date_format'
         24        SEND_VAR                                                 !1
         25        SEND_VAL                                                 'U'
         26        DO_ICALL                                         $14     
         27        CAST                                          4  ~15     $14
         28        QM_ASSIGN                                        ~16     ~15
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~16     <false>
         31    >   ASSIGN                                                   !2, ~16
   15    32        ECHO                                                     'date_create%28%29'
   16    33        INIT_FCALL                                               'var_dump'
         34        SEND_VAR                                                 !2
         35        DO_ICALL                                                 
   17    36        INIT_FCALL                                               'date'
         37        SEND_VAL                                                 'Y-m-d+H%3Ai'
         38        SEND_VAR                                                 !2
         39        DO_ICALL                                         $19     
         40        CONCAT                                           ~20     'Entspricht%3A+', $19
         41        ECHO                                                     ~20
   18    42        ECHO                                                     '%3Cp%3E%3Chr%3E%3C%2Fp%3E'
   19    43      > RETURN                                                   null
   23    44    >   INIT_FCALL                                               'strtotime'
         45        SEND_VAR                                                 !0
         46        DO_ICALL                                         $21     
         47        ASSIGN                                                   !3, $21
   24    48        IS_EQUAL                                                 !3, -1
         49      > JMPZ                                                     ~23, ->51
         50    >   ASSIGN                                                   !3, <false>
   25    51    >   ECHO                                                     'strtotoime%28%29'
   26    52        INIT_FCALL                                               'var_dump'
         53        SEND_VAR                                                 !3
         54        DO_ICALL                                                 
   27    55        INIT_FCALL                                               'date'
         56        SEND_VAL                                                 'Y-m-d+H%3Ai'
         57        SEND_VAR                                                 !3
         58        DO_ICALL                                         $26     
         59        CONCAT                                           ~27     'Entspricht%3A+', $26
         60        ECHO                                                     ~27
   28    61        ECHO                                                     '%3Cp%3E%3Chr%3E%3C%2Fp%3E%0A'
   29    62      > RETURN                                                   null

End of function converttotimestamp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.53 ms | 1407 KiB | 35 Q