3v4l.org

run code in 300+ PHP versions simultaneously
<?php class UserModel { public $name = null, $occupation = null, $email = null, $oldname = null, $oldoccupation = null, $oldemail = null, $me, $handler, $result; public function __construct(){ } public function create($fields = array()){ if(count($fields) == 3){ $this->name = $fields['name']; $this->occupation = $fields['occupation']; $this->email = $fields['email']; } } public function _save(){ if($this->oldname == null && $this->oldoccupation == null && $this->oldemail == null){ $sql = "INSERT INTO users (name, occupation, email) VALUES ('".$this->name."', '".$this->occupation."', '".$this->email."')"; /*$this->result = $this->handler->prepare($sql); /$this->result->execute(array( ':name'=>$this->name, ':occupation'=>$this->occupation, ':email'=>$this->email ));*/ echo $sql; } else { $sql = "UPDATE users SET name = '".$this->name."', occupation = '".$this->occupation."', email = '".$this->email."' WHERE name = '".$this->oldname."'"; /*$this->result = $this->handler->prepare($sql); $this->result->execute(array( ':name'=>$this->name, ':occupation'=>$this->occupation, ':email'=>$this->email, ':oldname'=>$this->oldname ));*/ echo $sql; } } public function name($given_name = null) { if($this->name == null){ if($given_name != null){ $this->name = $given_name; } } else { if($given_name != null){ $this->oldname = $this->name; $this->name = $given_name; } } return $this->name; } public function occupation($given_occupation = null) { if($this->occupation == null){ if($given_occupation != null){ $this->occupation = $given_occupation; } } else { if($given_occupation != null){ $this->oldoccupation = $this->occupation; $this->occupation = $given_occupation; } } return $this->occupation; } public function email($given_email = null){ $this->verifyEmail($given_email); if($given_email != null){ // $this->oldemail = $this->email; // THIS LINE IS THE ISSUE $this->email = $given_email; } return $this->email; } public function verifyEmail($givenemail = null){ if($givenemail == null){ $email = $this->email; } else { $email = $givenemail; } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new Exception('Email not valid.'); die(); } } } $user = new UserModel(); $user->create(array( 'name' => 'Luke', 'occupation' => 'Programmer', 'email' => 'luke@gmail.com' )); $user->_save(); $user->name('Jack'); $user->occupation(); try { $user->email('demo@example.co.za'); } catch (Exception $e) { echo $e->getMessage(); } $user->_save();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 17
Branch analysis from position: 17
2 jumps found. (Code = 107) Position 1 = 18, Position 2 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tABue
function name:  (null)
number of ops:  24
compiled vars:  !0 = $user, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   94     0  E >   NEW                                              $2      'UserModel'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   95     3        INIT_METHOD_CALL                                         !0, 'create'
   96     4        SEND_VAL_EX                                              <array>
          5        DO_FCALL                                      0          
  100     6        INIT_METHOD_CALL                                         !0, '_save'
          7        DO_FCALL                                      0          
  101     8        INIT_METHOD_CALL                                         !0, 'name'
          9        SEND_VAL_EX                                              'Jack'
         10        DO_FCALL                                      0          
  102    11        INIT_METHOD_CALL                                         !0, 'occupation'
         12        DO_FCALL                                      0          
  104    13        INIT_METHOD_CALL                                         !0, 'email'
         14        SEND_VAL_EX                                              'demo%40example.co.za'
         15        DO_FCALL                                      0          
         16      > JMP                                                      ->21
  105    17  E > > CATCH                                       last         'Exception'
  106    18    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         19        DO_FCALL                                      0  $10     
         20        ECHO                                                     $10
  108    21    >   INIT_METHOD_CALL                                         !0, '_save'
         22        DO_FCALL                                      0          
         23      > RETURN                                                   1

Class UserModel:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tABue
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E > > RETURN                                                   null

End of function __construct

Function create:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/tABue
function name:  create
number of ops:  14
compiled vars:  !0 = $fields
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV_INIT                                        !0      <array>
   11     1        COUNT                                            ~1      !0
          2        IS_EQUAL                                                 ~1, 3
          3      > JMPZ                                                     ~2, ->13
   12     4    >   FETCH_DIM_R                                      ~4      !0, 'name'
          5        ASSIGN_OBJ                                               'name'
          6        OP_DATA                                                  ~4
   13     7        FETCH_DIM_R                                      ~6      !0, 'occupation'
          8        ASSIGN_OBJ                                               'occupation'
          9        OP_DATA                                                  ~6
   14    10        FETCH_DIM_R                                      ~8      !0, 'email'
         11        ASSIGN_OBJ                                               'email'
         12        OP_DATA                                                  ~8
   17    13    > > RETURN                                                   null

End of function create

Function _save:
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 = 46) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
Branch analysis from position: 6
filename:       /in/tABue
function name:  _save
number of ops:  38
compiled vars:  !0 = $sql
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   FETCH_OBJ_R                                      ~1      'oldname'
          1        IS_EQUAL                                         ~2      ~1, null
          2      > JMPZ_EX                                          ~2      ~2, ->6
          3    >   FETCH_OBJ_R                                      ~3      'oldoccupation'
          4        IS_EQUAL                                         ~4      ~3, null
          5        BOOL                                             ~2      ~4
          6    > > JMPZ_EX                                          ~2      ~2, ->10
          7    >   FETCH_OBJ_R                                      ~5      'oldemail'
          8        IS_EQUAL                                         ~6      ~5, null
          9        BOOL                                             ~2      ~6
         10    > > JMPZ                                                     ~2, ->23
   21    11    >   FETCH_OBJ_R                                      ~7      'name'
         12        CONCAT                                           ~8      'INSERT+INTO+users+%28name%2C+occupation%2C+email%29+VALUES+%28%27', ~7
         13        CONCAT                                           ~9      ~8, '%27%2C+%27'
         14        FETCH_OBJ_R                                      ~10     'occupation'
         15        CONCAT                                           ~11     ~9, ~10
         16        CONCAT                                           ~12     ~11, '%27%2C+%27'
         17        FETCH_OBJ_R                                      ~13     'email'
         18        CONCAT                                           ~14     ~12, ~13
         19        CONCAT                                           ~15     ~14, '%27%29'
         20        ASSIGN                                                   !0, ~15
   28    21        ECHO                                                     !0
         22      > JMP                                                      ->37
   30    23    >   FETCH_OBJ_R                                      ~17     'name'
         24        CONCAT                                           ~18     'UPDATE+users+SET+name+%3D+%27', ~17
         25        CONCAT                                           ~19     ~18, '%27%2C+occupation+%3D+%27'
         26        FETCH_OBJ_R                                      ~20     'occupation'
         27        CONCAT                                           ~21     ~19, ~20
         28        CONCAT                                           ~22     ~21, '%27%2C+email+%3D+%27'
         29        FETCH_OBJ_R                                      ~23     'email'
         30        CONCAT                                           ~24     ~22, ~23
         31        CONCAT                                           ~25     ~24, '%27+WHERE+name+%3D+%27'
         32        FETCH_OBJ_R                                      ~26     'oldname'
         33        CONCAT                                           ~27     ~25, ~26
         34        CONCAT                                           ~28     ~27, '%27'
         35        ASSIGN                                                   !0, ~28
   38    36        ECHO                                                     !0
   40    37    > > RETURN                                                   null

End of function _save

Function name:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/tABue
function name:  name
number of ops:  19
compiled vars:  !0 = $given_name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV_INIT                                        !0      null
   43     1        FETCH_OBJ_R                                      ~1      'name'
          2        IS_EQUAL                                                 ~1, null
          3      > JMPZ                                                     ~2, ->9
   44     4    >   IS_NOT_EQUAL                                             !0, null
          5      > JMPZ                                                     ~3, ->8
   45     6    >   ASSIGN_OBJ                                               'name'
          7        OP_DATA                                                  !0
          8    > > JMP                                                      ->16
   48     9    >   IS_NOT_EQUAL                                             !0, null
         10      > JMPZ                                                     ~5, ->16
   49    11    >   FETCH_OBJ_R                                      ~7      'name'
         12        ASSIGN_OBJ                                               'oldname'
         13        OP_DATA                                                  ~7
   50    14        ASSIGN_OBJ                                               'name'
         15        OP_DATA                                                  !0
   53    16    >   FETCH_OBJ_R                                      ~9      'name'
         17      > RETURN                                                   ~9
   54    18*     > RETURN                                                   null

End of function name

Function occupation:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/tABue
function name:  occupation
number of ops:  19
compiled vars:  !0 = $given_occupation
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   RECV_INIT                                        !0      null
   57     1        FETCH_OBJ_R                                      ~1      'occupation'
          2        IS_EQUAL                                                 ~1, null
          3      > JMPZ                                                     ~2, ->9
   58     4    >   IS_NOT_EQUAL                                             !0, null
          5      > JMPZ                                                     ~3, ->8
   59     6    >   ASSIGN_OBJ                                               'occupation'
          7        OP_DATA                                                  !0
          8    > > JMP                                                      ->16
   62     9    >   IS_NOT_EQUAL                                             !0, null
         10      > JMPZ                                                     ~5, ->16
   63    11    >   FETCH_OBJ_R                                      ~7      'occupation'
         12        ASSIGN_OBJ                                               'oldoccupation'
         13        OP_DATA                                                  ~7
   64    14        ASSIGN_OBJ                                               'occupation'
         15        OP_DATA                                                  !0
   67    16    >   FETCH_OBJ_R                                      ~9      'occupation'
         17      > RETURN                                                   ~9
   68    18*     > RETURN                                                   null

End of function occupation

Function email:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/tABue
function name:  email
number of ops:  11
compiled vars:  !0 = $given_email
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   RECV_INIT                                        !0      null
   71     1        INIT_METHOD_CALL                                         'verifyEmail'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   72     4        IS_NOT_EQUAL                                             !0, null
          5      > JMPZ                                                     ~2, ->8
   74     6    >   ASSIGN_OBJ                                               'email'
          7        OP_DATA                                                  !0
   76     8    >   FETCH_OBJ_R                                      ~4      'email'
          9      > RETURN                                                   ~4
   77    10*     > RETURN                                                   null

End of function email

Function verifyemail:
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 = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
Branch analysis from position: 18
filename:       /in/tABue
function name:  verifyEmail
number of ops:  19
compiled vars:  !0 = $givenemail, !1 = $email
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   79     0  E >   RECV_INIT                                        !0      null
   80     1        IS_EQUAL                                                 !0, null
          2      > JMPZ                                                     ~2, ->6
   81     3    >   FETCH_OBJ_R                                      ~3      'email'
          4        ASSIGN                                                   !1, ~3
          5      > JMP                                                      ->7
   83     6    >   ASSIGN                                                   !1, !0
   86     7    >   INIT_FCALL                                               'filter_var'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 274
         10        DO_ICALL                                         $6      
         11        BOOL_NOT                                         ~7      $6
         12      > JMPZ                                                     ~7, ->18
   87    13    >   NEW                                              $8      'Exception'
         14        SEND_VAL_EX                                              'Email+not+valid.'
         15        DO_FCALL                                      0          
         16      > THROW                                         0          $8
   88    17*       EXIT                                                     
   91    18    > > RETURN                                                   null

End of function verifyemail

End of class UserModel.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.9 ms | 1412 KiB | 15 Q