3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Employee { protected $salary; public function __construct($salary) { $this->salary = $salary; } public function getSalary() { return $this->salary; } } class Manager extends Employee { protected $bonus; public function __construct($salary, $bonus) { parent::__construct($salary); $this->bonus = $bonus; } public function getSalary() { return $this->salary + $this->bonus; } } function printEmployeeSalary(Employee $employee) { echo "Salary: " . $employee->getSalary() . "\n"; } $employee = new Employee(3000); $manager = new Manager(5000, 2000); printEmployeeSalary($employee); // Ожидается: Salary: 3000 printEmployeeSalary($manager); // Ожидается: Salary: 7000
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XUoBa
function name:  (null)
number of ops:  16
compiled vars:  !0 = $employee, !1 = $manager
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   NEW                                              $2      'Employee'
          1        SEND_VAL_EX                                              3000
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   41     4        NEW                                              $5      'Manager'
          5        SEND_VAL_EX                                              5000
          6        SEND_VAL_EX                                              2000
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $5
   43     9        INIT_FCALL                                               'printemployeesalary'
         10        SEND_VAR                                                 !0
         11        DO_FCALL                                      0          
   44    12        INIT_FCALL                                               'printemployeesalary'
         13        SEND_VAR                                                 !1
         14        DO_FCALL                                      0          
         15      > RETURN                                                   1

Function printemployeesalary:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XUoBa
function name:  printEmployeeSalary
number of ops:  7
compiled vars:  !0 = $employee
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   37     1        INIT_METHOD_CALL                                         !0, 'getSalary'
          2        DO_FCALL                                      0  $1      
          3        CONCAT                                           ~2      'Salary%3A+', $1
          4        CONCAT                                           ~3      ~2, '%0A'
          5        ECHO                                                     ~3
   38     6      > RETURN                                                   null

End of function printemployeesalary

Class Employee:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XUoBa
function name:  __construct
number of ops:  4
compiled vars:  !0 = $salary
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        ASSIGN_OBJ                                               'salary'
          2        OP_DATA                                                  !0
   11     3      > RETURN                                                   null

End of function __construct

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

End of function getsalary

End of class Employee.

Class Manager:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XUoBa
function name:  __construct
number of ops:  8
compiled vars:  !0 = $salary, !1 = $bonus
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   25     2        INIT_STATIC_METHOD_CALL                                  
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   26     5        ASSIGN_OBJ                                               'bonus'
          6        OP_DATA                                                  !1
   27     7      > RETURN                                                   null

End of function __construct

Function getsalary:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XUoBa
function name:  getSalary
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   FETCH_OBJ_R                                      ~0      'salary'
          1        FETCH_OBJ_R                                      ~1      'bonus'
          2        ADD                                              ~2      ~0, ~1
          3      > RETURN                                                   ~2
   32     4*     > RETURN                                                   null

End of function getsalary

End of class Manager.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.25 ms | 1457 KiB | 15 Q