3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NotDefined { public function setDirection($direction) { $this->direction = $direction; } public function getDirection() { return $this->direction; } } class PropertyDefined { protected $direction; public function setDirection($direction) { $this->direction = $direction; } public function getDirection() { return $this->direction; } } function getCost($class) { $start = memory_get_usage(); $instance = new $class; $instance->setDirection('asc'); $cost = memory_get_usage() - $start . ' bytes'; unset($instance); return $cost; } // Output the cost WITHOUT a property declared echo 'Not declared' . getCost(NotDefined::class) . PHP_EOL; // Output the cost WITH the property declared echo 'Declared' . getCost(PropertyDefined::class);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CjTTN
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'getcost'
          1        SEND_VAL                                                 'NotDefined'
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      'Not+declared', $0
          4        CONCAT                                           ~2      ~1, '%0A'
          5        ECHO                                                     ~2
   39     6        INIT_FCALL                                               'getcost'
          7        SEND_VAL                                                 'PropertyDefined'
          8        DO_FCALL                                      0  $3      
          9        CONCAT                                           ~4      'Declared', $3
         10        ECHO                                                     ~4
         11      > RETURN                                                   1

Function getcost:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CjTTN
function name:  getCost
number of ops:  19
compiled vars:  !0 = $class, !1 = $start, !2 = $instance, !3 = $cost
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   24     1        INIT_FCALL                                               'memory_get_usage'
          2        DO_ICALL                                         $4      
          3        ASSIGN                                                   !1, $4
   26     4        FETCH_CLASS                                   0  $6      !0
          5        NEW                                              $7      $6
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $7
   27     8        INIT_METHOD_CALL                                         !2, 'setDirection'
          9        SEND_VAL_EX                                              'asc'
         10        DO_FCALL                                      0          
   29    11        INIT_FCALL                                               'memory_get_usage'
         12        DO_ICALL                                         $11     
         13        SUB                                              ~12     $11, !1
         14        CONCAT                                           ~13     ~12, '+bytes'
         15        ASSIGN                                                   !3, ~13
   30    16        UNSET_CV                                                 !2
   32    17      > RETURN                                                   !3
   33    18*     > RETURN                                                   null

End of function getcost

Class NotDefined:
Function setdirection:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CjTTN
function name:  setDirection
number of ops:  4
compiled vars:  !0 = $direction
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        ASSIGN_OBJ                                               'direction'
          2        OP_DATA                                                  !0
    6     3      > RETURN                                                   null

End of function setdirection

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

End of function getdirection

End of class NotDefined.

Class PropertyDefined:
Function setdirection:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CjTTN
function name:  setDirection
number of ops:  4
compiled vars:  !0 = $direction
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        ASSIGN_OBJ                                               'direction'
          2        OP_DATA                                                  !0
   17     3      > RETURN                                                   null

End of function setdirection

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

End of function getdirection

End of class PropertyDefined.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.61 ms | 1403 KiB | 17 Q