3v4l.org

run code in 300+ PHP versions simultaneously
<?php // データ定義 $data = array( array( '入力項目1', 'チェックボックス1', '選択1', 'あいうえお', ), array( '入力項目2', 'チェックボックス2', '選択2', 'アイウエオ', ), ); // 例外処理ブロック try { // DB接続 if (!($link = @mysql_connect('localhost', 'ABCD', 'EFGH'))) { throw new RuntimeException('DB接続に失敗しました。'); } // 文字セット指定 mysql_set_charset('utf8', $link); // DB選択 if (!@mysql_select_db('test_db', $link)) { throw new RuntimeException('DB選択に失敗しました。'); } // SQL文フォーマット $format = 'INSERT ' . 'INTO `product_b` (`text`, `checkbox`, `setntaku`, `textarea`) ' . 'VALUES (%s, %s, %s, %s)' ; foreach ($data as $d) { // 値をエスケープ $d = array_map( function ($i) use ($link) { return mysql_real_escape_string($i, $link); }, $d ); // 値をバインドしてSQL実行 if (!mysql_query(vprintf($format, $d), $link)) { throw new RuntimeException('データ挿入に失敗しました。'); } } // 正常時 $message = 'エラーはありません。'; } catch (RuntimeException $e) { // 例外が発生したとき $message = htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8'); } // ブラウザにcharsetを伝える header('Content-Type: text/html; charset=utf-8'); ?> <!DOCTYPE html> <html> <head> <title>Test</title> </head> <body> <p><?=$message?></p> </body> </html>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 56
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 56
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 55
Branch analysis from position: 51
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
Found catch point at position: 59
Branch analysis from position: 59
2 jumps found. (Code = 107) Position 1 = 60, Position 2 = -2
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nOfXD
function name:  (null)
number of ops:  75
compiled vars:  !0 = $data, !1 = $link, !2 = $format, !3 = $d, !4 = $message, !5 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   23     1        BEGIN_SILENCE                                    ~7      
          2        INIT_FCALL_BY_NAME                                       'mysql_connect'
          3        SEND_VAL_EX                                              'localhost'
          4        SEND_VAL_EX                                              'ABCD'
          5        SEND_VAL_EX                                              'EFGH'
          6        DO_FCALL                                      0  $8      
          7        END_SILENCE                                              ~7
          8        ASSIGN                                           ~9      !1, $8
          9        BOOL_NOT                                         ~10     ~9
         10      > JMPZ                                                     ~10, ->15
   24    11    >   NEW                                              $11     'RuntimeException'
         12        SEND_VAL_EX                                              'DB%E6%8E%A5%E7%B6%9A%E3%81%AB%E5%A4%B1%E6%95%97%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82'
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $11
   28    15    >   INIT_FCALL_BY_NAME                                       'mysql_set_charset'
         16        SEND_VAL_EX                                              'utf8'
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0          
   31    19        BEGIN_SILENCE                                    ~14     
         20        INIT_FCALL_BY_NAME                                       'mysql_select_db'
         21        SEND_VAL_EX                                              'test_db'
         22        SEND_VAR_EX                                              !1
         23        DO_FCALL                                      0  $15     
         24        END_SILENCE                                              ~14
         25        BOOL_NOT                                         ~16     $15
         26      > JMPZ                                                     ~16, ->31
   32    27    >   NEW                                              $17     'RuntimeException'
         28        SEND_VAL_EX                                              'DB%E9%81%B8%E6%8A%9E%E3%81%AB%E5%A4%B1%E6%95%97%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82'
         29        DO_FCALL                                      0          
         30      > THROW                                         0          $17
   36    31    >   ASSIGN                                                   !2, 'INSERT+INTO+%60product_b%60+%28%60text%60%2C+%60checkbox%60%2C+%60setntaku%60%2C+%60textarea%60%29+VALUES+%28%25s%2C+%25s%2C+%25s%2C+%25s%29'
   41    32      > FE_RESET_R                                       $20     !0, ->56
         33    > > FE_FETCH_R                                               $20, !3, ->56
   43    34    >   INIT_FCALL                                               'array_map'
   44    35        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FnOfXD%3A44%240'
         36        BIND_LEXICAL                                             ~21, !1
   46    37        SEND_VAL                                                 ~21
   47    38        SEND_VAR                                                 !3
         39        DO_ICALL                                         $22     
   43    40        ASSIGN                                                   !3, $22
   50    41        INIT_FCALL_BY_NAME                                       'mysql_query'
         42        INIT_FCALL                                               'vprintf'
         43        SEND_VAR                                                 !2
         44        SEND_VAR                                                 !3
         45        DO_ICALL                                         $24     
         46        SEND_VAR_NO_REF_EX                                       $24
         47        SEND_VAR_EX                                              !1
         48        DO_FCALL                                      0  $25     
         49        BOOL_NOT                                         ~26     $25
         50      > JMPZ                                                     ~26, ->55
   51    51    >   NEW                                              $27     'RuntimeException'
         52        SEND_VAL_EX                                              '%E3%83%87%E3%83%BC%E3%82%BF%E6%8C%BF%E5%85%A5%E3%81%AB%E5%A4%B1%E6%95%97%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82'
         53        DO_FCALL                                      0          
         54      > THROW                                         0          $27
   41    55    > > JMP                                                      ->33
         56    >   FE_FREE                                                  $20
   56    57        ASSIGN                                                   !4, '%E3%82%A8%E3%83%A9%E3%83%BC%E3%81%AF%E3%81%82%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82'
         58      > JMP                                                      ->68
   58    59  E > > CATCH                                       last         'RuntimeException'
   61    60    >   INIT_FCALL                                               'htmlspecialchars'
         61        INIT_METHOD_CALL                                         !5, 'getMessage'
         62        DO_FCALL                                      0  $30     
         63        SEND_VAR                                                 $30
         64        SEND_VAL                                                 3
         65        SEND_VAL                                                 'UTF-8'
         66        DO_ICALL                                         $31     
         67        ASSIGN                                                   !4, $31
   66    68    >   INIT_FCALL                                               'header'
         69        SEND_VAL                                                 'Content-Type%3A+text%2Fhtml%3B+charset%3Dutf-8'
         70        DO_ICALL                                                 
   69    71        ECHO                                                     '%3C%21DOCTYPE+html%3E%0A%3Chtml%3E%0A++%3Chead%3E%0A++++%3Ctitle%3ETest%3C%2Ftitle%3E%0A++%3C%2Fhead%3E%0A++%3Cbody%3E%0A++++%3Cp%3E'
   75    72        ECHO                                                     !4
         73        ECHO                                                     '%3C%2Fp%3E%0A++%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   77    74      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FnOfXD%3A44%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nOfXD
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $i, !1 = $link
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   45     2        INIT_FCALL_BY_NAME                                       'mysql_real_escape_string'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
   46     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FnOfXD%3A44%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.92 ms | 1404 KiB | 21 Q