3v4l.org

run code in 500+ PHP versions simultaneously
<?php require_once './functionPHP.php'; class Users { public $_email; public $_password; public $_error = ''; public $_showBooks = false; protected $_userId = null; public function __construct($email, $password) { $this->_email = $email; $this->_password = $password; } public function Check() { if ($this->_email != '' && $this->_password != '') { $connect = connect(); $email = mysqli_real_escape_string($connect, $this->_email); $query = "SELECT user_id, user_password FROM users WHERE user_email = '$email'"; $result = mysqli_query($connect, $query); if (mysqli_num_rows($result) == 1) { $user = mysqli_fetch_assoc($result); if ($this->_password == $user['user_password']) { $this->_showBooks = true; $this->_userId = $user['user_id']; } else { $this->_error = 'Неверный пароль'; } } else { $this->_error = 'Пользователь с таким email не найден'; } mysqli_close($connect); } else { $this->_error = 'Заполните оба поля'; } } public function getError() { return $this->_error; } public function getShowBooks() { return $this->_showBooks; } public function getId() { return $this->_userId; } } class Registration { public string $_email; public string $_password; public string $_repeatPassword; public array $_errors = []; public bool $_success = false; public function __construct(string $email, string $password, string $repeatPassword) { $this->_email = htmlentities($email); $this->_password = htmlentities($password); $this->_repeatPassword = htmlentities($repeatPassword); } public function register(): void { $connect = connect(); if ($this->_password !== $this->_repeatPassword) { echo $this->_errors[] = 'Введите одинаковые пароли'; return; } $email = mysqli_real_escape_string($connect, $this->_email); $query = "SELECT COUNT(*) AS `count` FROM `users` WHERE `user_email` = '$email'"; $result = mysqli_query($connect, $query); $count = mysqli_fetch_assoc($result)['count']; if ($count > 0) { echo $this->_errors[] = 'Такой email уже существует'; mysqli_close($connect); return; } $query = "INSERT INTO `users` (user_email, user_password) VALUES ('$email', '{$this->_password}')"; mysqli_query($connect, $query); mysqli_close($connect); $this->_success = true; } public function getErrors(): array { return $this->_errors; } public function isSuccess(): bool { return $this->_success; } } class Logout{ public static function exit() { session_destroy(); header('Location: ./авторизация.php'); exit; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TTuV
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   INCLUDE_OR_EVAL                                              '.%2FfunctionPHP.php', REQUIRE_ONCE
  109     1      > RETURN                                                       1

Class Users:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TTuV
function name:  __construct
number of ops:  7
compiled vars:  !0 = $email, !1 = $password
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   12     2        ASSIGN_OBJ                                                   '_email'
          3        OP_DATA                                                      !0
   13     4        ASSIGN_OBJ                                                   '_password'
          5        OP_DATA                                                      !1
   14     6      > RETURN                                                       null

End of function __construct

Function check:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 54
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 48
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 45
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/4TTuV
function name:  Check
number of ops:  57
compiled vars:  !0 = $connect, !1 = $email, !2 = $query, !3 = $result, !4 = $user
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   FETCH_OBJ_R                                          ~5      '_email'
          1        IS_NOT_EQUAL                                         ~6      ~5, ''
          2      > JMPZ_EX                                              ~6      ~6, ->6
          3    >   FETCH_OBJ_R                                          ~7      '_password'
          4        IS_NOT_EQUAL                                         ~8      ~7, ''
          5        BOOL                                                 ~6      ~8
          6    > > JMPZ                                                         ~6, ->54
   18     7    >   INIT_FCALL_BY_NAME                                           'connect'
          8        DO_FCALL                                          0  $9      
          9        ASSIGN                                                       !0, $9
   19    10        INIT_FCALL_BY_NAME                                           'mysqli_real_escape_string'
         11        SEND_VAR_EX                                                  !0
         12        CHECK_FUNC_ARG                                               
         13        FETCH_OBJ_FUNC_ARG                                   $11     '_email'
         14        SEND_FUNC_ARG                                                $11
         15        DO_FCALL                                          0  $12     
         16        ASSIGN                                                       !1, $12
   20    17        ROPE_INIT                                         3  ~15     'SELECT+user_id%2C+user_password+FROM+users+WHERE+user_email+%3D+%27'
         18        ROPE_ADD                                          1  ~15     ~15, !1
         19        ROPE_END                                          2  ~14     ~15, '%27'
         20        ASSIGN                                                       !2, ~14
   21    21        INIT_FCALL_BY_NAME                                           'mysqli_query'
         22        SEND_VAR_EX                                                  !0
         23        SEND_VAR_EX                                                  !2
         24        DO_FCALL                                          0  $18     
         25        ASSIGN                                                       !3, $18
   22    26        INIT_FCALL_BY_NAME                                           'mysqli_num_rows'
         27        SEND_VAR_EX                                                  !3
         28        DO_FCALL                                          0  $20     
         29        IS_EQUAL                                                     $20, 1
         30      > JMPZ                                                         ~21, ->48
   23    31    >   INIT_FCALL_BY_NAME                                           'mysqli_fetch_assoc'
         32        SEND_VAR_EX                                                  !3
         33        DO_FCALL                                          0  $22     
         34        ASSIGN                                                       !4, $22
   24    35        FETCH_OBJ_R                                          ~24     '_password'
         36        FETCH_DIM_R                                          ~25     !4, 'user_password'
         37        IS_EQUAL                                                     ~24, ~25
         38      > JMPZ                                                         ~26, ->45
   25    39    >   ASSIGN_OBJ                                                   '_showBooks'
         40        OP_DATA                                                      <true>
   26    41        FETCH_DIM_R                                          ~29     !4, 'user_id'
         42        ASSIGN_OBJ                                                   '_userId'
         43        OP_DATA                                                      ~29
   24    44      > JMP                                                          ->47
   28    45    >   ASSIGN_OBJ                                                   '_error'
         46        OP_DATA                                                      '%D0%9D%D0%B5%D0%B2%D0%B5%D1%80%D0%BD%D1%8B%D0%B9+%D0%BF%D0%B0%D1%80%D0%BE%D0%BB%D1%8C'
   22    47    > > JMP                                                          ->50
   31    48    >   ASSIGN_OBJ                                                   '_error'
         49        OP_DATA                                                      '%D0%9F%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8C+%D1%81+%D1%82%D0%B0%D0%BA%D0%B8%D0%BC+email+%D0%BD%D0%B5+%D0%BD%D0%B0%D0%B9%D0%B4%D0%B5%D0%BD'
   33    50    >   INIT_FCALL_BY_NAME                                           'mysqli_close'
         51        SEND_VAR_EX                                                  !0
         52        DO_FCALL                                          0          
   17    53      > JMP                                                          ->56
   35    54    >   ASSIGN_OBJ                                                   '_error'
         55        OP_DATA                                                      '%D0%97%D0%B0%D0%BF%D0%BE%D0%BB%D0%BD%D0%B8%D1%82%D0%B5+%D0%BE%D0%B1%D0%B0+%D0%BF%D0%BE%D0%BB%D1%8F'
   37    56    > > RETURN                                                       null

End of function check

Function geterror:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TTuV
function name:  getError
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   40     0  E >   FETCH_OBJ_R                                          ~0      '_error'
          1      > RETURN                                                       ~0
   41     2*     > RETURN                                                       null

End of function geterror

Function getshowbooks:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TTuV
function name:  getShowBooks
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   44     0  E >   FETCH_OBJ_R                                          ~0      '_showBooks'
          1      > RETURN                                                       ~0
   45     2*     > RETURN                                                       null

End of function getshowbooks

Function getid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TTuV
function name:  getId
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   47     0  E >   FETCH_OBJ_R                                          ~0      '_userId'
          1      > RETURN                                                       ~0
   48     2*     > RETURN                                                       null

End of function getid

End of class Users.

Class Registration:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TTuV
function name:  __construct
number of ops:  19
compiled vars:  !0 = $email, !1 = $password, !2 = $repeatPassword
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   59     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   61     3        INIT_FCALL                                                   'htmlentities'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $4      
          6        ASSIGN_OBJ                                                   '_email'
          7        OP_DATA                                                      $4
   62     8        INIT_FCALL                                                   'htmlentities'
          9        SEND_VAR                                                     !1
         10        DO_ICALL                                             $6      
         11        ASSIGN_OBJ                                                   '_password'
         12        OP_DATA                                                      $6
   63    13        INIT_FCALL                                                   'htmlentities'
         14        SEND_VAR                                                     !2
         15        DO_ICALL                                             $8      
         16        ASSIGN_OBJ                                                   '_repeatPassword'
         17        OP_DATA                                                      $8
   64    18      > RETURN                                                       null

End of function __construct

Function register:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 43
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TTuV
function name:  register
number of ops:  60
compiled vars:  !0 = $connect, !1 = $email, !2 = $query, !3 = $result, !4 = $count
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   68     0  E >   INIT_FCALL_BY_NAME                                           'connect'
          1        DO_FCALL                                          0  $5      
          2        ASSIGN                                                       !0, $5
   70     3        FETCH_OBJ_R                                          ~7      '_password'
          4        FETCH_OBJ_R                                          ~8      '_repeatPassword'
          5        IS_NOT_IDENTICAL                                             ~7, ~8
          6      > JMPZ                                                         ~9, ->12
   71     7    >   FETCH_OBJ_W                                          $10     '_errors'
          8        ASSIGN_DIM                                           ~11     $10
          9        OP_DATA                                                      '%D0%92%D0%B2%D0%B5%D0%B4%D0%B8%D1%82%D0%B5+%D0%BE%D0%B4%D0%B8%D0%BD%D0%B0%D0%BA%D0%BE%D0%B2%D1%8B%D0%B5+%D0%BF%D0%B0%D1%80%D0%BE%D0%BB%D0%B8'
         10        ECHO                                                         ~11
   72    11      > RETURN                                                       null
   75    12    >   INIT_FCALL_BY_NAME                                           'mysqli_real_escape_string'
         13        SEND_VAR_EX                                                  !0
         14        CHECK_FUNC_ARG                                               
         15        FETCH_OBJ_FUNC_ARG                                   $12     '_email'
         16        SEND_FUNC_ARG                                                $12
         17        DO_FCALL                                          0  $13     
         18        ASSIGN                                                       !1, $13
   76    19        ROPE_INIT                                         3  ~16     'SELECT+COUNT%28%2A%29+AS+%60count%60+FROM+%60users%60+WHERE+%60user_email%60+%3D+%27'
         20        ROPE_ADD                                          1  ~16     ~16, !1
         21        ROPE_END                                          2  ~15     ~16, '%27'
         22        ASSIGN                                                       !2, ~15
   77    23        INIT_FCALL_BY_NAME                                           'mysqli_query'
         24        SEND_VAR_EX                                                  !0
         25        SEND_VAR_EX                                                  !2
         26        DO_FCALL                                          0  $19     
         27        ASSIGN                                                       !3, $19
   78    28        INIT_FCALL_BY_NAME                                           'mysqli_fetch_assoc'
         29        SEND_VAR_EX                                                  !3
         30        DO_FCALL                                          0  $21     
         31        FETCH_DIM_R                                          ~22     $21, 'count'
         32        ASSIGN                                                       !4, ~22
   79    33        IS_SMALLER                                                   0, !4
         34      > JMPZ                                                         ~24, ->43
   80    35    >   FETCH_OBJ_W                                          $25     '_errors'
         36        ASSIGN_DIM                                           ~26     $25
         37        OP_DATA                                                      '%D0%A2%D0%B0%D0%BA%D0%BE%D0%B9+email+%D1%83%D0%B6%D0%B5+%D1%81%D1%83%D1%89%D0%B5%D1%81%D1%82%D0%B2%D1%83%D0%B5%D1%82'
         38        ECHO                                                         ~26
   81    39        INIT_FCALL_BY_NAME                                           'mysqli_close'
         40        SEND_VAR_EX                                                  !0
         41        DO_FCALL                                          0          
   82    42      > RETURN                                                       null
   85    43    >   ROPE_INIT                                         5  ~30     'INSERT+INTO+%60users%60+%28user_email%2C+user_password%29+VALUES+%28%27'
         44        ROPE_ADD                                          1  ~30     ~30, !1
         45        ROPE_ADD                                          2  ~30     ~30, '%27%2C+%27'
         46        FETCH_OBJ_R                                          ~28     '_password'
         47        ROPE_ADD                                          3  ~30     ~30, ~28
         48        ROPE_END                                          4  ~29     ~30, '%27%29'
         49        ASSIGN                                                       !2, ~29
   86    50        INIT_FCALL_BY_NAME                                           'mysqli_query'
         51        SEND_VAR_EX                                                  !0
         52        SEND_VAR_EX                                                  !2
         53        DO_FCALL                                          0          
   87    54        INIT_FCALL_BY_NAME                                           'mysqli_close'
         55        SEND_VAR_EX                                                  !0
         56        DO_FCALL                                          0          
   89    57        ASSIGN_OBJ                                                   '_success'
         58        OP_DATA                                                      <true>
   90    59      > RETURN                                                       null

End of function register

Function geterrors:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TTuV
function name:  getErrors
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   94     0  E >   FETCH_OBJ_R                                          ~0      '_errors'
          1        VERIFY_RETURN_TYPE                                           ~0
          2      > RETURN                                                       ~0
   95     3*       VERIFY_RETURN_TYPE                                           
          4*     > RETURN                                                       null

End of function geterrors

Function issuccess:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TTuV
function name:  isSuccess
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   99     0  E >   FETCH_OBJ_R                                          ~0      '_success'
          1        VERIFY_RETURN_TYPE                                           ~0
          2      > RETURN                                                       ~0
  100     3*       VERIFY_RETURN_TYPE                                           
          4*     > RETURN                                                       null

End of function issuccess

End of class Registration.

Class Logout:
Function exit:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 61) Position 1 = -2
filename:       /in/4TTuV
function name:  exit
number of ops:  8
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  105     0  E >   INIT_FCALL                                                   'session_destroy'
          1        DO_ICALL                                                     
  106     2        INIT_FCALL                                                   'header'
          3        SEND_VAL                                                     'Location%3A+.%2F%D0%B0%D0%B2%D1%82%D0%BE%D1%80%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F.php'
          4        DO_ICALL                                                     
  107     5      > INIT_FCALL                                                   'exit'
          6*       DO_ICALL                                                     
  108     7*     > RETURN                                                       null

End of function exit

End of class Logout.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.32 ms | 1426 KiB | 17 Q