3v4l.org

run code in 300+ PHP versions simultaneously
<? abstract class StudentManager { abstract function getStudent($previousStudent); abstract function getStudentCount(); abstract function setStudentCount($new_count); abstract function addStudent($oneStudent); abstract function removeStudent($oneStudent); } class SingleStudentClass extends StudentManager { private $firstName; private $lastName; function __construct($firstName, $lastName) { $this->firstName = $firstName; $this->lastName = $lastName; } function getStudent($studentToGet) { if (1 == $studentToGet) { return $this->firstName." by ".$this->lastName; } else { return FALSE; } } function getStudentCount() { return 1; } function setStudentCount($newCount) { return FALSE; } function addStudent($oneStudent) { return FALSE; } function removeStudent($oneStudent) { return FALSE; } } class MultipleStudentsClass extends StudentManager { private $oneStudents = array(); private $studentCount; public function __construct() { $this->setStudentCount(0); } public function getStudentCount() { return $this->studentCount; } public function setStudentCount($newCount) { $this->studentCount = $newCount; } public function getStudent($studentToGet) { if ($studentToGet <= $this->studentCount) { return $this->oneStudents[$studentToGet]->getStudent(1); } else { return FALSE; } } public function addStudent($oneStudent) { $this->setStudentCount($this->getStudentCount() + 1); $this->oneStudents[$this->getStudentCount()] = $oneStudent; return $this->getStudentCount(); } public function removeStudent($oneStudent) { $counter = 0; while (++$counter <= $this->getStudentCount()) { if ($oneStudent->getStudent(1) == $this->oneStudents[$counter]->getStudent(1)) { for ($x = $counter; $x < $this->getStudentCount(); $x++) { $this->oneStudents[$x] = $this->oneStudents[$x + 1]; } $this->setStudentCount($this->getStudentCount() - 1); } } return $this->getStudentCount(); } } $firstStudent = new SingleStudentClass("A","B"); echo $firstStudent->getStudent(1); echo "<BR>"; $secondStudent = new SingleStudentClass("C", "D"); echo $secondStudent->getStudent(1); echo "<BR>"; $students = new MultipleStudentsClass(); $studentsCount = $students->addStudent($firstStudent); echo $students->getStudent($studentsCount); echo "<BR>"; $studentsCount = $students->addStudent($secondStudent); echo $students->getStudent($studentsCount); echo "<BR>"; $studentsCount = $students->removeStudent($firstStudent); echo $students->getStudentCount(); echo "<BR>"; echo $students->getStudent(1); echo "<BR>"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  (null)
number of ops:  55
compiled vars:  !0 = $firstStudent, !1 = $secondStudent, !2 = $students, !3 = $studentsCount
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   95     0  E >   NEW                                              $4      'SingleStudentClass'
          1        SEND_VAL_EX                                              'A'
          2        SEND_VAL_EX                                              'B'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $4
   96     5        INIT_METHOD_CALL                                         !0, 'getStudent'
          6        SEND_VAL_EX                                              1
          7        DO_FCALL                                      0  $7      
          8        ECHO                                                     $7
   97     9        ECHO                                                     '%3CBR%3E'
  100    10        NEW                                              $8      'SingleStudentClass'
         11        SEND_VAL_EX                                              'C'
         12        SEND_VAL_EX                                              'D'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !1, $8
  101    15        INIT_METHOD_CALL                                         !1, 'getStudent'
         16        SEND_VAL_EX                                              1
         17        DO_FCALL                                      0  $11     
         18        ECHO                                                     $11
  102    19        ECHO                                                     '%3CBR%3E'
  104    20        NEW                                              $12     'MultipleStudentsClass'
         21        DO_FCALL                                      0          
         22        ASSIGN                                                   !2, $12
  105    23        INIT_METHOD_CALL                                         !2, 'addStudent'
         24        SEND_VAR_EX                                              !0
         25        DO_FCALL                                      0  $15     
         26        ASSIGN                                                   !3, $15
  106    27        INIT_METHOD_CALL                                         !2, 'getStudent'
         28        SEND_VAR_EX                                              !3
         29        DO_FCALL                                      0  $17     
         30        ECHO                                                     $17
  107    31        ECHO                                                     '%3CBR%3E'
  109    32        INIT_METHOD_CALL                                         !2, 'addStudent'
         33        SEND_VAR_EX                                              !1
         34        DO_FCALL                                      0  $18     
         35        ASSIGN                                                   !3, $18
  110    36        INIT_METHOD_CALL                                         !2, 'getStudent'
         37        SEND_VAR_EX                                              !3
         38        DO_FCALL                                      0  $20     
         39        ECHO                                                     $20
  111    40        ECHO                                                     '%3CBR%3E'
  113    41        INIT_METHOD_CALL                                         !2, 'removeStudent'
         42        SEND_VAR_EX                                              !0
         43        DO_FCALL                                      0  $21     
         44        ASSIGN                                                   !3, $21
  114    45        INIT_METHOD_CALL                                         !2, 'getStudentCount'
         46        DO_FCALL                                      0  $23     
         47        ECHO                                                     $23
  115    48        ECHO                                                     '%3CBR%3E'
  117    49        INIT_METHOD_CALL                                         !2, 'getStudent'
         50        SEND_VAL_EX                                              1
         51        DO_FCALL                                      0  $24     
         52        ECHO                                                     $24
  118    53        ECHO                                                     '%3CBR%3E'
  119    54      > RETURN                                                   1

Class StudentManager:
Function getstudent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  getStudent
number of ops:  2
compiled vars:  !0 = $previousStudent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function getstudent

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

End of function getstudentcount

Function setstudentcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  setStudentCount
number of ops:  2
compiled vars:  !0 = $new_count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function setstudentcount

Function addstudent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  addStudent
number of ops:  2
compiled vars:  !0 = $oneStudent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function addstudent

Function removestudent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  removeStudent
number of ops:  2
compiled vars:  !0 = $oneStudent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function removestudent

End of class StudentManager.

Class SingleStudentClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  __construct
number of ops:  7
compiled vars:  !0 = $firstName, !1 = $lastName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        ASSIGN_OBJ                                               'firstName'
          3        OP_DATA                                                  !0
   18     4        ASSIGN_OBJ                                               'lastName'
          5        OP_DATA                                                  !1
   19     6      > RETURN                                                   null

End of function __construct

Function getstudent:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  getStudent
number of ops:  11
compiled vars:  !0 = $studentToGet
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        IS_EQUAL                                                 !0, 1
          2      > JMPZ                                                     ~1, ->9
   23     3    >   FETCH_OBJ_R                                      ~2      'firstName'
          4        CONCAT                                           ~3      ~2, '+by+'
          5        FETCH_OBJ_R                                      ~4      'lastName'
          6        CONCAT                                           ~5      ~3, ~4
          7      > RETURN                                                   ~5
          8*       JMP                                                      ->10
   25     9    > > RETURN                                                   <false>
   27    10*     > RETURN                                                   null

End of function getstudent

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

End of function getstudentcount

Function setstudentcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  setStudentCount
number of ops:  3
compiled vars:  !0 = $newCount
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   34     1      > RETURN                                                   <false>
   35     2*     > RETURN                                                   null

End of function setstudentcount

Function addstudent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  addStudent
number of ops:  3
compiled vars:  !0 = $oneStudent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   38     1      > RETURN                                                   <false>
   39     2*     > RETURN                                                   null

End of function addstudent

Function removestudent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  removeStudent
number of ops:  3
compiled vars:  !0 = $oneStudent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
   42     1      > RETURN                                                   <false>
   43     2*     > RETURN                                                   null

End of function removestudent

End of class SingleStudentClass.

Class MultipleStudentsClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   INIT_METHOD_CALL                                         'setStudentCount'
          1        SEND_VAL_EX                                              0
          2        DO_FCALL                                      0          
   55     3      > RETURN                                                   null

End of function __construct

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

End of function getstudentcount

Function setstudentcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  setStudentCount
number of ops:  4
compiled vars:  !0 = $newCount
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV                                             !0      
   61     1        ASSIGN_OBJ                                               'studentCount'
          2        OP_DATA                                                  !0
   62     3      > RETURN                                                   null

End of function setstudentcount

Function getstudent:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  getStudent
number of ops:  13
compiled vars:  !0 = $studentToGet
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
   65     1        FETCH_OBJ_R                                      ~1      'studentCount'
          2        IS_SMALLER_OR_EQUAL                                      !0, ~1
          3      > JMPZ                                                     ~2, ->11
   66     4    >   FETCH_OBJ_R                                      ~3      'oneStudents'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6        INIT_METHOD_CALL                                         ~4, 'getStudent'
          7        SEND_VAL_EX                                              1
          8        DO_FCALL                                      0  $5      
          9      > RETURN                                                   $5
         10*       JMP                                                      ->12
   68    11    > > RETURN                                                   <false>
   70    12*     > RETURN                                                   null

End of function getstudent

Function addstudent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vIOhl
function name:  addStudent
number of ops:  16
compiled vars:  !0 = $oneStudent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   72     0  E >   RECV                                             !0      
   73     1        INIT_METHOD_CALL                                         'setStudentCount'
          2        INIT_METHOD_CALL                                         'getStudentCount'
          3        DO_FCALL                                      0  $1      
          4        ADD                                              ~2      $1, 1
          5        SEND_VAL_EX                                              ~2
          6        DO_FCALL                                      0          
   74     7        INIT_METHOD_CALL                                         'getStudentCount'
          8        DO_FCALL                                      0  $5      
          9        FETCH_OBJ_W                                      $4      'oneStudents'
         10        ASSIGN_DIM                                               $4, $5
         11        OP_DATA                                                  !0
   75    12        INIT_METHOD_CALL                                         'getStudentCount'
         13        DO_FCALL                                      0  $7      
         14      > RETURN                                                   $7
   76    15*     > RETURN                                                   null

End of function addstudent

Function removestudent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 3
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 32
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 15
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 3
Branch analysis from position: 37
Branch analysis from position: 3
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 15
Branch analysis from position: 26
Branch analysis from position: 15
Branch analysis from position: 32
filename:       /in/vIOhl
function name:  removeStudent
number of ops:  41
compiled vars:  !0 = $oneStudent, !1 = $counter, !2 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   78     0  E >   RECV                                             !0      
   79     1        ASSIGN                                                   !1, 0
   80     2      > JMP                                                      ->32
   81     3    >   INIT_METHOD_CALL                                         !0, 'getStudent'
          4        SEND_VAL_EX                                              1
          5        DO_FCALL                                      0  $4      
   82     6        FETCH_OBJ_R                                      ~5      'oneStudents'
          7        FETCH_DIM_R                                      ~6      ~5, !1
          8        INIT_METHOD_CALL                                         ~6, 'getStudent'
          9        SEND_VAL_EX                                              1
         10        DO_FCALL                                      0  $7      
         11        IS_EQUAL                                                 $4, $7
         12      > JMPZ                                                     ~8, ->32
   83    13    >   ASSIGN                                                   !2, !1
         14      > JMP                                                      ->22
   84    15    >   ADD                                              ~13     !2, 1
         16        FETCH_OBJ_R                                      ~12     'oneStudents'
         17        FETCH_DIM_R                                      ~14     ~12, ~13
         18        FETCH_OBJ_W                                      $10     'oneStudents'
         19        ASSIGN_DIM                                               $10, !2
         20        OP_DATA                                                  ~14
   83    21        PRE_INC                                                  !2
         22    >   INIT_METHOD_CALL                                         'getStudentCount'
         23        DO_FCALL                                      0  $16     
         24        IS_SMALLER                                               !2, $16
         25      > JMPNZ                                                    ~17, ->15
   86    26    >   INIT_METHOD_CALL                                         'setStudentCount'
         27        INIT_METHOD_CALL                                         'getStudentCount'
         28        DO_FCALL                                      0  $18     
         29        SUB                                              ~19     $18, 1
         30        SEND_VAL_EX                                              ~19
         31        DO_FCALL                                      0          
   80    32    >   PRE_INC                                          ~21     !1
         33        INIT_METHOD_CALL                                         'getStudentCount'
         34        DO_FCALL                                      0  $22     
         35        IS_SMALLER_OR_EQUAL                                      ~21, $22
         36      > JMPNZ                                                    ~23, ->3
   89    37    >   INIT_METHOD_CALL                                         'getStudentCount'
         38        DO_FCALL                                      0  $24     
         39      > RETURN                                                   $24
   90    40*     > RETURN                                                   null

End of function removestudent

End of class MultipleStudentsClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.15 ms | 1406 KiB | 13 Q