3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Animal { protected $what = "nothing"; protected $born; // Add this: public function__construct(){} // only when class does not explicity specify a constructor // ? would the constructor be visible to users or like JAVA invisible // // Below code has a constructor so default constructor doesn't get created // public function __construct() { // $this->setBirthDate(); // } function sound() { echo get_class($this)." says {$this->what}"; } function showBirthDate() { return $this->born; } function setBirthdate() { $this->born = time(); } } class Cow extends Animal { protected $what = "moo"; protected $owner; public function __construct($owner) { $this->owner = $owner; // by default this would always be called so no need to write it parent::__construct(); } } $a = new Cow("Old McDonald"); $a->sound(); //echo "\nCow born: ",date("M j, Y",$a->showBirthDate());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Roccj
function name:  (null)
number of ops:  7
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   NEW                                              $1      'Cow'
          1        SEND_VAL_EX                                              'Old+McDonald'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   41     4        INIT_METHOD_CALL                                         !0, 'sound'
          5        DO_FCALL                                      0          
   42     6      > RETURN                                                   1

Class Animal:
Function sound:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Roccj
function name:  sound
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_THIS                                       ~0      
          1        GET_CLASS                                        ~1      ~0
          2        NOP                                                      
          3        FETCH_OBJ_R                                      ~2      'what'
          4        FAST_CONCAT                                      ~3      '+says+', ~2
          5        CONCAT                                           ~4      ~1, ~3
          6        ECHO                                                     ~4
   20     7      > RETURN                                                   null

End of function sound

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

End of function showbirthdate

Function setbirthdate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Roccj
function name:  setBirthdate
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                               'time'
          1        DO_ICALL                                         $1      
          2        ASSIGN_OBJ                                               'born'
          3        OP_DATA                                                  $1
   26     4      > RETURN                                                   null

End of function setbirthdate

End of class Animal.

Class Cow:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Roccj
function name:  __construct
number of ops:  6
compiled vars:  !0 = $owner
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   34     1        ASSIGN_OBJ                                               'owner'
          2        OP_DATA                                                  !0
   36     3        INIT_STATIC_METHOD_CALL                                  
          4        DO_FCALL                                      0          
   37     5      > RETURN                                                   null

End of function __construct

Function sound:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Roccj
function name:  sound
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_THIS                                       ~0      
          1        GET_CLASS                                        ~1      ~0
          2        NOP                                                      
          3        FETCH_OBJ_R                                      ~2      'what'
          4        FAST_CONCAT                                      ~3      '+says+', ~2
          5        CONCAT                                           ~4      ~1, ~3
          6        ECHO                                                     ~4
   20     7      > RETURN                                                   null

End of function sound

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

End of function showbirthdate

Function setbirthdate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Roccj
function name:  setBirthdate
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                               'time'
          1        DO_ICALL                                         $1      
          2        ASSIGN_OBJ                                               'born'
          3        OP_DATA                                                  $1
   26     4      > RETURN                                                   null

End of function setbirthdate

End of class Cow.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.5 ms | 1400 KiB | 15 Q