3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MySQLDao { var $dbhost = null; var $dbuser = null; var $dbpass = null; var $conn = null; var $dbname = null; var $result = null; function __construct() { $this->dbhost = Conn::$dbhost; $this->dbuser = Conn::$dbuser; $this->dbpass = Conn::$dbpass; $this->dbname = Conn::$dbname; } public function openConnection() { $this->conn = new mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname); if (mysqli_connect_errno()) echo new Exception("Could not establish connection with database"); } public function getConnection() { return $this->conn; } public function closeConnection() { if ($this->conn != null) $this->conn->close(); } public function getUserDetails($Facebookid) { $returnValue = array(); $sql = "select * from Users where FacebookId='" . $Facebookid . "'"; $result = $this->conn->query($sql); if ($result != null && (mysqli_num_rows($result) >= 1)) { $row = $result->fetch_array(MYSQLI_ASSOC); if (!empty($row)) { $returnValue = $row; } } return $returnValue; } /* public function getUserDetailsWithPassword($email, $userPassword) { $returnValue = array(); $sql = "select id,user_email from users where user_email='" . $email . "' and user_password='" .$userPassword . "'"; $result = $this->conn->query($sql); if ($result != null && (mysqli_num_rows($result) >= 1)) { $row = $result->fetch_array(MYSQLI_ASSOC); if (!empty($row)) { $returnValue = $row; } } return $returnValue; } */ public function registerUser($Facebookid, $firstname, $lastname, $FBpictureURL, $Gender, $UserEmail) { $sql = "insert into Users FacebookId=?, firstname=?, lastname=?, FBpictureURL=?, Gender=?, UserEmail=?"; $statement = $this->conn->prepare($sql); if (!$statement) throw new Exception($statement->error); $statement->bind_param("isssss", $Facebookid, $firstname, $lastname, $FBpictureURL, $Gender, $UserEmail); $returnValue = $statement->execute(); return $returnValue; } } ?> Register.php <?php require("Conn.php"); require("MySQLDao.php"); $Facebookid = htmlentities($_POST["Facebookid"]); $firstname = htmlentities($_POST["firstname"]); $lastname = htmlentities($_POST["lastname"]); $FBPictureURL = htmlentities($_POST["FBPictureURL"]); $Gender = htmlentities($_POST["Gender"]); $UserEmail = htmlentities($_POST["UserEmail"]); $returnValue = array(); $dao = new MySQLDao(); $dao->openConnection(); $userDetails = $dao->getUserDetails($email); if(!empty($userDetails)) { $returnValue["status"] = "Success"; $returnValue["message"] = "User already exists, so Login"; $returnValue["userid"] = "Test"; $returnValue["firstname"] = "Test"; $returnValue["Gender"] = "Test"; $returnValue["FBPictureURL"] = "Test"; echo json_encode($returnValue); return; } $result = $dao->registerUser($Facebookid, $firstname, $lastname, $FBPictureURL, $Gender, $UserEmail); if($result) { $returnValue["status"] = "Success"; $returnValue["message"] = "New User is registered, so Login"; $returnValue["userid"] = "Test"; $returnValue["firstname"] = "Test"; $returnValue["Gender"] = "Test"; $returnValue["FBPictureURL"] = "Test"; echo json_encode($returnValue); return; } $dao->closeConnection(); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 69
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 79, Position 2 = 96
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 96
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ULIv0
function name:  (null)
number of ops:  99
compiled vars:  !0 = $Facebookid, !1 = $firstname, !2 = $lastname, !3 = $FBPictureURL, !4 = $Gender, !5 = $UserEmail, !6 = $returnValue, !7 = $dao, !8 = $userDetails, !9 = $email, !10 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   80     0  E >   ECHO                                                     '%0A+%0A%0ARegister.php%0A%0A'
   87     1        INCLUDE_OR_EVAL                                          'Conn.php', REQUIRE
   88     2        INCLUDE_OR_EVAL                                          'MySQLDao.php', REQUIRE
   90     3        INIT_FCALL                                               'htmlentities'
          4        FETCH_R                      global              ~13     '_POST'
          5        FETCH_DIM_R                                      ~14     ~13, 'Facebookid'
          6        SEND_VAL                                                 ~14
          7        DO_ICALL                                         $15     
          8        ASSIGN                                                   !0, $15
   91     9        INIT_FCALL                                               'htmlentities'
         10        FETCH_R                      global              ~17     '_POST'
         11        FETCH_DIM_R                                      ~18     ~17, 'firstname'
         12        SEND_VAL                                                 ~18
         13        DO_ICALL                                         $19     
         14        ASSIGN                                                   !1, $19
   92    15        INIT_FCALL                                               'htmlentities'
         16        FETCH_R                      global              ~21     '_POST'
         17        FETCH_DIM_R                                      ~22     ~21, 'lastname'
         18        SEND_VAL                                                 ~22
         19        DO_ICALL                                         $23     
         20        ASSIGN                                                   !2, $23
   93    21        INIT_FCALL                                               'htmlentities'
         22        FETCH_R                      global              ~25     '_POST'
         23        FETCH_DIM_R                                      ~26     ~25, 'FBPictureURL'
         24        SEND_VAL                                                 ~26
         25        DO_ICALL                                         $27     
         26        ASSIGN                                                   !3, $27
   94    27        INIT_FCALL                                               'htmlentities'
         28        FETCH_R                      global              ~29     '_POST'
         29        FETCH_DIM_R                                      ~30     ~29, 'Gender'
         30        SEND_VAL                                                 ~30
         31        DO_ICALL                                         $31     
         32        ASSIGN                                                   !4, $31
   95    33        INIT_FCALL                                               'htmlentities'
         34        FETCH_R                      global              ~33     '_POST'
         35        FETCH_DIM_R                                      ~34     ~33, 'UserEmail'
         36        SEND_VAL                                                 ~34
         37        DO_ICALL                                         $35     
         38        ASSIGN                                                   !5, $35
   97    39        ASSIGN                                                   !6, <array>
   99    40        NEW                                              $38     'MySQLDao'
         41        DO_FCALL                                      0          
         42        ASSIGN                                                   !7, $38
  100    43        INIT_METHOD_CALL                                         !7, 'openConnection'
         44        DO_FCALL                                      0          
  101    45        INIT_METHOD_CALL                                         !7, 'getUserDetails'
         46        SEND_VAR_EX                                              !9
         47        DO_FCALL                                      0  $42     
         48        ASSIGN                                                   !8, $42
  103    49        ISSET_ISEMPTY_CV                                 ~44     !8
         50        BOOL_NOT                                         ~45     ~44
         51      > JMPZ                                                     ~45, ->69
  105    52    >   ASSIGN_DIM                                               !6, 'status'
         53        OP_DATA                                                  'Success'
  106    54        ASSIGN_DIM                                               !6, 'message'
         55        OP_DATA                                                  'User+already+exists%2C+so+Login'
  108    56        ASSIGN_DIM                                               !6, 'userid'
         57        OP_DATA                                                  'Test'
  109    58        ASSIGN_DIM                                               !6, 'firstname'
         59        OP_DATA                                                  'Test'
  110    60        ASSIGN_DIM                                               !6, 'Gender'
         61        OP_DATA                                                  'Test'
  111    62        ASSIGN_DIM                                               !6, 'FBPictureURL'
         63        OP_DATA                                                  'Test'
  112    64        INIT_FCALL                                               'json_encode'
         65        SEND_VAR                                                 !6
         66        DO_ICALL                                         $52     
         67        ECHO                                                     $52
  113    68      > RETURN                                                   null
  117    69    >   INIT_METHOD_CALL                                         !7, 'registerUser'
         70        SEND_VAR_EX                                              !0
         71        SEND_VAR_EX                                              !1
         72        SEND_VAR_EX                                              !2
         73        SEND_VAR_EX                                              !3
         74        SEND_VAR_EX                                              !4
         75        SEND_VAR_EX                                              !5
         76        DO_FCALL                                      0  $53     
         77        ASSIGN                                                   !10, $53
  119    78      > JMPZ                                                     !10, ->96
  121    79    >   ASSIGN_DIM                                               !6, 'status'
         80        OP_DATA                                                  'Success'
  122    81        ASSIGN_DIM                                               !6, 'message'
         82        OP_DATA                                                  'New+User+is+registered%2C+so+Login'
  124    83        ASSIGN_DIM                                               !6, 'userid'
         84        OP_DATA                                                  'Test'
  125    85        ASSIGN_DIM                                               !6, 'firstname'
         86        OP_DATA                                                  'Test'
  126    87        ASSIGN_DIM                                               !6, 'Gender'
         88        OP_DATA                                                  'Test'
  127    89        ASSIGN_DIM                                               !6, 'FBPictureURL'
         90        OP_DATA                                                  'Test'
  128    91        INIT_FCALL                                               'json_encode'
         92        SEND_VAR                                                 !6
         93        DO_ICALL                                         $61     
         94        ECHO                                                     $61
  129    95      > RETURN                                                   null
  134    96    >   INIT_METHOD_CALL                                         !7, 'closeConnection'
         97        DO_FCALL                                      0          
  138    98      > RETURN                                                   1

Class MySQLDao:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ULIv0
function name:  __construct
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_STATIC_PROP_R          unknown             ~1      'dbhost'
          1        ASSIGN_OBJ                                               'dbhost'
          2        OP_DATA                                                  ~1
   13     3        FETCH_STATIC_PROP_R          unknown             ~3      'dbuser'
          4        ASSIGN_OBJ                                               'dbuser'
          5        OP_DATA                                                  ~3
   14     6        FETCH_STATIC_PROP_R          unknown             ~5      'dbpass'
          7        ASSIGN_OBJ                                               'dbpass'
          8        OP_DATA                                                  ~5
   15     9        FETCH_STATIC_PROP_R          unknown             ~7      'dbname'
         10        ASSIGN_OBJ                                               'dbname'
         11        OP_DATA                                                  ~7
   16    12      > RETURN                                                   null

End of function __construct

Function openconnection:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/ULIv0
function name:  openConnection
number of ops:  24
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $1      'mysqli'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $2      'dbhost'
          3        SEND_FUNC_ARG                                            $2
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $3      'dbuser'
          6        SEND_FUNC_ARG                                            $3
          7        CHECK_FUNC_ARG                                           
          8        FETCH_OBJ_FUNC_ARG                               $4      'dbpass'
          9        SEND_FUNC_ARG                                            $4
         10        CHECK_FUNC_ARG                                           
         11        FETCH_OBJ_FUNC_ARG                               $5      'dbname'
         12        SEND_FUNC_ARG                                            $5
         13        DO_FCALL                                      0          
         14        ASSIGN_OBJ                                               'conn'
         15        OP_DATA                                                  $1
   20    16        INIT_FCALL_BY_NAME                                       'mysqli_connect_errno'
         17        DO_FCALL                                      0  $7      
         18      > JMPZ                                                     $7, ->23
   21    19    >   NEW                                              $8      'Exception'
         20        SEND_VAL_EX                                              'Could+not+establish+connection+with+database'
         21        DO_FCALL                                      0          
         22        ECHO                                                     $8
   22    23    > > RETURN                                                   null

End of function openconnection

Function getconnection:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ULIv0
function name:  getConnection
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   FETCH_OBJ_R                                      ~0      'conn'
          1      > RETURN                                                   ~0
   26     2*     > RETURN                                                   null

End of function getconnection

Function closeconnection:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/ULIv0
function name:  closeConnection
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   FETCH_OBJ_R                                      ~0      'conn'
          1        IS_NOT_EQUAL                                             ~0, null
          2      > JMPZ                                                     ~1, ->6
   30     3    >   FETCH_OBJ_R                                      ~2      'conn'
          4        INIT_METHOD_CALL                                         ~2, 'close'
          5        DO_FCALL                                      0          
   31     6    > > RETURN                                                   null

End of function closeconnection

Function getuserdetails:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 27
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 27
Branch analysis from position: 17
filename:       /in/ULIv0
function name:  getUserDetails
number of ops:  29
compiled vars:  !0 = $Facebookid, !1 = $returnValue, !2 = $sql, !3 = $result, !4 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   35     1        ASSIGN                                                   !1, <array>
   36     2        CONCAT                                           ~6      'select+%2A+from+Users+where+FacebookId%3D%27', !0
          3        CONCAT                                           ~7      ~6, '%27'
          4        ASSIGN                                                   !2, ~7
   38     5        FETCH_OBJ_R                                      ~9      'conn'
          6        INIT_METHOD_CALL                                         ~9, 'query'
          7        SEND_VAR_EX                                              !2
          8        DO_FCALL                                      0  $10     
          9        ASSIGN                                                   !3, $10
   39    10        IS_NOT_EQUAL                                     ~12     !3, null
         11      > JMPZ_EX                                          ~12     ~12, ->17
         12    >   INIT_FCALL_BY_NAME                                       'mysqli_num_rows'
         13        SEND_VAR_EX                                              !3
         14        DO_FCALL                                      0  $13     
         15        IS_SMALLER_OR_EQUAL                              ~14     1, $13
         16        BOOL                                             ~12     ~14
         17    > > JMPZ                                                     ~12, ->27
   40    18    >   INIT_METHOD_CALL                                         !3, 'fetch_array'
         19        FETCH_CONSTANT                                   ~15     'MYSQLI_ASSOC'
         20        SEND_VAL_EX                                              ~15
         21        DO_FCALL                                      0  $16     
         22        ASSIGN                                                   !4, $16
   41    23        ISSET_ISEMPTY_CV                                 ~18     !4
         24        BOOL_NOT                                         ~19     ~18
         25      > JMPZ                                                     ~19, ->27
   42    26    >   ASSIGN                                                   !1, !4
   45    27    > > RETURN                                                   !1
   46    28*     > RETURN                                                   null

End of function getuserdetails

Function registeruser:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ULIv0
function name:  registerUser
number of ops:  34
compiled vars:  !0 = $Facebookid, !1 = $firstname, !2 = $lastname, !3 = $FBpictureURL, !4 = $Gender, !5 = $UserEmail, !6 = $sql, !7 = $statement, !8 = $returnValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV                                             !5      
   65     6        ASSIGN                                                   !6, 'insert+into+Users+FacebookId%3D%3F%2C+firstname%3D%3F%2C+lastname%3D%3F%2C+FBpictureURL%3D%3F%2C+Gender%3D%3F%2C+UserEmail%3D%3F'
   66     7        FETCH_OBJ_R                                      ~10     'conn'
          8        INIT_METHOD_CALL                                         ~10, 'prepare'
          9        SEND_VAR_EX                                              !6
         10        DO_FCALL                                      0  $11     
         11        ASSIGN                                                   !7, $11
   68    12        BOOL_NOT                                         ~13     !7
         13      > JMPZ                                                     ~13, ->20
   69    14    >   NEW                                              $14     'Exception'
         15        CHECK_FUNC_ARG                                           
         16        FETCH_OBJ_FUNC_ARG                               $15     !7, 'error'
         17        SEND_FUNC_ARG                                            $15
         18        DO_FCALL                                      0          
         19      > THROW                                         0          $14
   71    20    >   INIT_METHOD_CALL                                         !7, 'bind_param'
         21        SEND_VAL_EX                                              'isssss'
         22        SEND_VAR_EX                                              !0
         23        SEND_VAR_EX                                              !1
         24        SEND_VAR_EX                                              !2
         25        SEND_VAR_EX                                              !3
         26        SEND_VAR_EX                                              !4
         27        SEND_VAR_EX                                              !5
         28        DO_FCALL                                      0          
   72    29        INIT_METHOD_CALL                                         !7, 'execute'
         30        DO_FCALL                                      0  $18     
         31        ASSIGN                                                   !8, $18
   74    32      > RETURN                                                   !8
   75    33*     > RETURN                                                   null

End of function registeruser

End of class MySQLDao.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.55 ms | 1416 KiB | 17 Q