3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Tell mysqli to throw an exception if an error occurs */ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = new \mysqli("localhost", "my_user", "my_password", "world"); /* The table engine has to support transactions */ $mysqli->query("CREATE TABLE IF NOT EXISTS language ( Code text NOT NULL, Speakers int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); /* Start transaction */ $mysqli->begin_transaction(); try { /* Insert some values */ $mysqli->query("INSERT INTO language(Code, Speakers) VALUES ('DE', 42000123)"); /* Try to insert invalid values */ $language_code = 'FR'; $native_speakers = 'Unknown'; $stmt = $mysqli->prepare('INSERT INTO language(Code, Speakers) VALUES (?,?)'); $stmt->bind_param('ss', $language_code, $native_speakers); $stmt->execute(); /* If code reaches this point without errors then commit the data in database */ $mysqli->commit(); } catch (\mysqli_sql_exception $exception) { $mysqli->rollback(); throw $exception; } /************************** * Procedural ***************************** / /* Tell mysqli to throw an exception if an error occurs */ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = mysqli_connect("localhost", "my_user", "my_password", "world"); /* The table engine has to support transactions */ mysqli_query($mysqli, "CREATE TABLE IF NOT EXISTS language ( Code text NOT NULL, Speakers int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); /* Start transaction */ mysqli_begin_transaction($mysqli); try { /* Insert some values */ mysqli_query($mysqli, "INSERT INTO language(Code, Speakers) VALUES ('DE', 42000123)"); /* Try to insert invalid values */ $language_code = 'FR'; $native_speakers = 'Unknown'; $stmt = mysqli_prepare($mysqli, 'INSERT INTO language(Code, Speakers) VALUES (?,?)'); mysqli_stmt_bind_param($stmt, 'ss', $language_code, $native_speakers); mysqli_stmt_execute($stmt); /* If code reaches this point without errors then commit the data in database */ mysqli_commit($mysqli); } catch (\mysqli_sql_exception $exception) { mysqli_rollback($mysqli); throw $exception; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 90
Branch analysis from position: 90
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 37
Branch analysis from position: 37
2 jumps found. (Code = 107) Position 1 = 38, Position 2 = -2
Branch analysis from position: 38
1 jumps found. (Code = 108) Position 1 = -2
Found catch point at position: 85
Branch analysis from position: 85
2 jumps found. (Code = 107) Position 1 = 86, Position 2 = -2
Branch analysis from position: 86
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/9jIdh
function name:  (null)
number of ops:  91
compiled vars:  !0 = $mysqli, !1 = $language_code, !2 = $native_speakers, !3 = $stmt, !4 = $exception
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL_BY_NAME                                       'mysqli_report'
          1        FETCH_CONSTANT                                   ~5      'MYSQLI_REPORT_ERROR'
          2        FETCH_CONSTANT                                   ~6      'MYSQLI_REPORT_STRICT'
          3        BW_OR                                            ~7      ~5, ~6
          4        SEND_VAL_EX                                              ~7
          5        DO_FCALL                                      0          
    6     6        NEW                                              $9      'mysqli'
          7        SEND_VAL_EX                                              'localhost'
          8        SEND_VAL_EX                                              'my_user'
          9        SEND_VAL_EX                                              'my_password'
         10        SEND_VAL_EX                                              'world'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !0, $9
    9    13        INIT_METHOD_CALL                                         !0, 'query'
         14        SEND_VAL_EX                                              'CREATE+TABLE+IF+NOT+EXISTS+language+%28%0A%09Code+text+NOT+NULL%2C%0A%09Speakers+int%2811%29+NOT+NULL%0A++%29+ENGINE%3DInnoDB+DEFAULT+CHARSET%3Dutf8mb4%3B'
         15        DO_FCALL                                      0          
   15    16        INIT_METHOD_CALL                                         !0, 'begin_transaction'
         17        DO_FCALL                                      0          
   19    18        INIT_METHOD_CALL                                         !0, 'query'
         19        SEND_VAL_EX                                              'INSERT+INTO+language%28Code%2C+Speakers%29+VALUES+%28%27DE%27%2C+42000123%29'
         20        DO_FCALL                                      0          
   22    21        ASSIGN                                                   !1, 'FR'
   23    22        ASSIGN                                                   !2, 'Unknown'
   24    23        INIT_METHOD_CALL                                         !0, 'prepare'
         24        SEND_VAL_EX                                              'INSERT+INTO+language%28Code%2C+Speakers%29+VALUES+%28%3F%2C%3F%29'
         25        DO_FCALL                                      0  $17     
         26        ASSIGN                                                   !3, $17
   25    27        INIT_METHOD_CALL                                         !3, 'bind_param'
         28        SEND_VAL_EX                                              'ss'
         29        SEND_VAR_EX                                              !1
         30        SEND_VAR_EX                                              !2
         31        DO_FCALL                                      0          
   26    32        INIT_METHOD_CALL                                         !3, 'execute'
         33        DO_FCALL                                      0          
   29    34        INIT_METHOD_CALL                                         !0, 'commit'
         35        DO_FCALL                                      0          
         36      > JMP                                                      ->41
   30    37  E > > CATCH                                       last         'mysqli_sql_exception'
   31    38    >   INIT_METHOD_CALL                                         !0, 'rollback'
         39        DO_FCALL                                      0          
   33    40      > THROW                                         0          !4
   41    41    >   INIT_FCALL_BY_NAME                                       'mysqli_report'
         42        FETCH_CONSTANT                                   ~23     'MYSQLI_REPORT_ERROR'
         43        FETCH_CONSTANT                                   ~24     'MYSQLI_REPORT_STRICT'
         44        BW_OR                                            ~25     ~23, ~24
         45        SEND_VAL_EX                                              ~25
         46        DO_FCALL                                      0          
   43    47        INIT_FCALL_BY_NAME                                       'mysqli_connect'
         48        SEND_VAL_EX                                              'localhost'
         49        SEND_VAL_EX                                              'my_user'
         50        SEND_VAL_EX                                              'my_password'
         51        SEND_VAL_EX                                              'world'
         52        DO_FCALL                                      0  $27     
         53        ASSIGN                                                   !0, $27
   46    54        INIT_FCALL_BY_NAME                                       'mysqli_query'
         55        SEND_VAR_EX                                              !0
         56        SEND_VAL_EX                                              'CREATE+TABLE+IF+NOT+EXISTS+language+%28%0A%09Code+text+NOT+NULL%2C%0A%09Speakers+int%2811%29+NOT+NULL%0A++%29+ENGINE%3DInnoDB+DEFAULT+CHARSET%3Dutf8mb4%3B'
         57        DO_FCALL                                      0          
   52    58        INIT_FCALL_BY_NAME                                       'mysqli_begin_transaction'
         59        SEND_VAR_EX                                              !0
         60        DO_FCALL                                      0          
   56    61        INIT_FCALL_BY_NAME                                       'mysqli_query'
         62        SEND_VAR_EX                                              !0
         63        SEND_VAL_EX                                              'INSERT+INTO+language%28Code%2C+Speakers%29+VALUES+%28%27DE%27%2C+42000123%29'
         64        DO_FCALL                                      0          
   59    65        ASSIGN                                                   !1, 'FR'
   60    66        ASSIGN                                                   !2, 'Unknown'
   61    67        INIT_FCALL_BY_NAME                                       'mysqli_prepare'
         68        SEND_VAR_EX                                              !0
         69        SEND_VAL_EX                                              'INSERT+INTO+language%28Code%2C+Speakers%29+VALUES+%28%3F%2C%3F%29'
         70        DO_FCALL                                      0  $34     
         71        ASSIGN                                                   !3, $34
   62    72        INIT_FCALL_BY_NAME                                       'mysqli_stmt_bind_param'
         73        SEND_VAR_EX                                              !3
         74        SEND_VAL_EX                                              'ss'
         75        SEND_VAR_EX                                              !1
         76        SEND_VAR_EX                                              !2
         77        DO_FCALL                                      0          
   63    78        INIT_FCALL_BY_NAME                                       'mysqli_stmt_execute'
         79        SEND_VAR_EX                                              !3
         80        DO_FCALL                                      0          
   66    81        INIT_FCALL_BY_NAME                                       'mysqli_commit'
         82        SEND_VAR_EX                                              !0
         83        DO_FCALL                                      0          
         84      > JMP                                                      ->90
   67    85  E > > CATCH                                       last         'mysqli_sql_exception'
   68    86    >   INIT_FCALL_BY_NAME                                       'mysqli_rollback'
         87        SEND_VAR_EX                                              !0
         88        DO_FCALL                                      0          
   70    89      > THROW                                         0          !4
   71    90    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.38 ms | 1403 KiB | 13 Q