3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getGoals(){ $link = mysql_connect('localhost','root','root'); mysql_select_db("goal_database",$link); if (isset($_GET["pid"]) && isset($_GET["week"])) { $pid = intval($_GET["pid"]); $week = intval($_GET["week"]); $response = array(); $response["goals"] = array(); // Mysql select query to retrieve nutrition goal $nutrition_result = mysql_query("SELECT Description FROM Goals WHERE ParticipantID=$pid AND WeekNumber=$week AND Type='NUTRITION';"); $row = mysql_fetch_array($nutrition_result); $nutrition_goal = $row[0]; $tmp = array(); $tmp["nutrition"] = $nutrition_goal; array_push($response["goals"], $tmp); // Mysql query to retrieve exervise goal $exercise_result = mysql_query("SELECT Description FROM Goals WHERE ParticipantID=$pid AND WeekNumber=$week AND Type='EXERCISE';"); $row = mysql_fetch_array($exercise_result); $exercise_goal = $row[0]; $tmp["exercise"] = $exercise_goal; array_push($response["goals"], $tmp); // keeping response header to json header('Content-Type: application/json'); // echnoing json result echo json_encode($response); if (mysql_errno()) { $error = "MySQL error ".mysql_errno().": ".mysql_error()."\n<br>When executing:<br>\n$query\n<br>"; echo $error; } } } getGoals(); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XGTMs
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_FCALL                                               'getgoals'
          1        DO_FCALL                                      0          
   38     2      > RETURN                                                   1

Function getgoals:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 96
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 96
Branch analysis from position: 83
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 96
Branch analysis from position: 96
Branch analysis from position: 16
filename:       /in/XGTMs
function name:  getGoals
number of ops:  97
compiled vars:  !0 = $link, !1 = $pid, !2 = $week, !3 = $response, !4 = $nutrition_result, !5 = $row, !6 = $nutrition_goal, !7 = $tmp, !8 = $exercise_result, !9 = $exercise_goal, !10 = $error, !11 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'mysql_connect'
          1        SEND_VAL_EX                                              'localhost'
          2        SEND_VAL_EX                                              'root'
          3        SEND_VAL_EX                                              'root'
          4        DO_FCALL                                      0  $12     
          5        ASSIGN                                                   !0, $12
    4     6        INIT_FCALL_BY_NAME                                       'mysql_select_db'
          7        SEND_VAL_EX                                              'goal_database'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
    5    10        FETCH_IS                                         ~15     '_GET'
         11        ISSET_ISEMPTY_DIM_OBJ                         0  ~16     ~15, 'pid'
         12      > JMPZ_EX                                          ~16     ~16, ->16
         13    >   FETCH_IS                                         ~17     '_GET'
         14        ISSET_ISEMPTY_DIM_OBJ                         0  ~18     ~17, 'week'
         15        BOOL                                             ~16     ~18
         16    > > JMPZ                                                     ~16, ->96
    7    17    >   FETCH_R                      global              ~19     '_GET'
         18        FETCH_DIM_R                                      ~20     ~19, 'pid'
         19        CAST                                          4  ~21     ~20
         20        ASSIGN                                                   !1, ~21
    8    21        FETCH_R                      global              ~23     '_GET'
         22        FETCH_DIM_R                                      ~24     ~23, 'week'
         23        CAST                                          4  ~25     ~24
         24        ASSIGN                                                   !2, ~25
    9    25        ASSIGN                                                   !3, <array>
   10    26        ASSIGN_DIM                                               !3, 'goals'
         27        OP_DATA                                                  <array>
   12    28        INIT_FCALL_BY_NAME                                       'mysql_query'
         29        ROPE_INIT                                     5  ~30     'SELECT+Description+FROM+Goals+WHERE+ParticipantID%3D'
         30        ROPE_ADD                                      1  ~30     ~30, !1
         31        ROPE_ADD                                      2  ~30     ~30, '+AND+WeekNumber%3D'
         32        ROPE_ADD                                      3  ~30     ~30, !2
         33        ROPE_END                                      4  ~29     ~30, '+AND+Type%3D%27NUTRITION%27%3B'
         34        SEND_VAL_EX                                              ~29
         35        DO_FCALL                                      0  $33     
         36        ASSIGN                                                   !4, $33
   13    37        INIT_FCALL_BY_NAME                                       'mysql_fetch_array'
         38        SEND_VAR_EX                                              !4
         39        DO_FCALL                                      0  $35     
         40        ASSIGN                                                   !5, $35
   14    41        FETCH_DIM_R                                      ~37     !5, 0
         42        ASSIGN                                                   !6, ~37
   15    43        ASSIGN                                                   !7, <array>
   16    44        ASSIGN_DIM                                               !7, 'nutrition'
         45        OP_DATA                                                  !6
   17    46        INIT_FCALL                                               'array_push'
         47        FETCH_DIM_W                                      $41     !3, 'goals'
         48        SEND_REF                                                 $41
         49        SEND_VAR                                                 !7
         50        DO_ICALL                                                 
   19    51        INIT_FCALL_BY_NAME                                       'mysql_query'
         52        ROPE_INIT                                     5  ~44     'SELECT+Description+FROM+Goals+WHERE+ParticipantID%3D'
         53        ROPE_ADD                                      1  ~44     ~44, !1
         54        ROPE_ADD                                      2  ~44     ~44, '+AND+WeekNumber%3D'
         55        ROPE_ADD                                      3  ~44     ~44, !2
         56        ROPE_END                                      4  ~43     ~44, '+AND+Type%3D%27EXERCISE%27%3B'
         57        SEND_VAL_EX                                              ~43
         58        DO_FCALL                                      0  $47     
         59        ASSIGN                                                   !8, $47
   20    60        INIT_FCALL_BY_NAME                                       'mysql_fetch_array'
         61        SEND_VAR_EX                                              !8
         62        DO_FCALL                                      0  $49     
         63        ASSIGN                                                   !5, $49
   21    64        FETCH_DIM_R                                      ~51     !5, 0
         65        ASSIGN                                                   !9, ~51
   22    66        ASSIGN_DIM                                               !7, 'exercise'
         67        OP_DATA                                                  !9
   23    68        INIT_FCALL                                               'array_push'
         69        FETCH_DIM_W                                      $54     !3, 'goals'
         70        SEND_REF                                                 $54
         71        SEND_VAR                                                 !7
         72        DO_ICALL                                                 
   26    73        INIT_FCALL                                               'header'
         74        SEND_VAL                                                 'Content-Type%3A+application%2Fjson'
         75        DO_ICALL                                                 
   29    76        INIT_FCALL                                               'json_encode'
         77        SEND_VAR                                                 !3
         78        DO_ICALL                                         $57     
         79        ECHO                                                     $57
   31    80        INIT_FCALL_BY_NAME                                       'mysql_errno'
         81        DO_FCALL                                      0  $58     
         82      > JMPZ                                                     $58, ->96
   32    83    >   INIT_FCALL_BY_NAME                                       'mysql_errno'
         84        DO_FCALL                                      0  $59     
         85        CONCAT                                           ~60     'MySQL+error+', $59
         86        CONCAT                                           ~61     ~60, '%3A+'
         87        INIT_FCALL_BY_NAME                                       'mysql_error'
         88        DO_FCALL                                      0  $62     
         89        CONCAT                                           ~63     ~61, $62
         90        ROPE_INIT                                     3  ~65     '%0A%3Cbr%3EWhen+executing%3A%3Cbr%3E%0A'
         91        ROPE_ADD                                      1  ~65     ~65, !11
         92        ROPE_END                                      2  ~64     ~65, '%0A%3Cbr%3E'
         93        CONCAT                                           ~67     ~63, ~64
         94        ASSIGN                                                   !10, ~67
   33    95        ECHO                                                     !10
   36    96    > > RETURN                                                   null

End of function getgoals

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.95 ms | 1407 KiB | 20 Q