3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Pet { public $name; public function __construct ( $name ) { $this->name = $name; } public function speak ($what) { return $what; } } class Dog extends Pet { // Le he metido el null para que el parametro sea opcional public function speak ( $what = null ) { return $what ? parent::speak($what) : 'Woof Woof!'; /* // Otra alternativa para meter codigo mas complicado seria: if($what) return parent::speak($what); return 'Woof Woof'; */ } public function plays() { return 'fetch'; } } $charlie = new Dog ( 'Charlie' ); echo 'The dog\'s name is ' . $charlie->name . PHP_EOL; echo 'Speak of the super class: ' . $charlie->speak('hello, my name is ' . $charlie->name) . PHP_EOL; echo 'Speak of the dog class: ' . $charlie->speak() . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T8pXB
function name:  (null)
number of ops:  22
compiled vars:  !0 = $charlie
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   NEW                                              $1      'Dog'
          1        SEND_VAL_EX                                              'Charlie'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   45     4        FETCH_OBJ_R                                      ~4      !0, 'name'
          5        CONCAT                                           ~5      'The+dog%27s+name+is+', ~4
          6        CONCAT                                           ~6      ~5, '%0A'
          7        ECHO                                                     ~6
   46     8        INIT_METHOD_CALL                                         !0, 'speak'
          9        FETCH_OBJ_R                                      ~7      !0, 'name'
         10        CONCAT                                           ~8      'hello%2C+my+name+is+', ~7
         11        SEND_VAL_EX                                              ~8
         12        DO_FCALL                                      0  $9      
         13        CONCAT                                           ~10     'Speak+of+the+super+class%3A+', $9
         14        CONCAT                                           ~11     ~10, '%0A'
         15        ECHO                                                     ~11
   47    16        INIT_METHOD_CALL                                         !0, 'speak'
         17        DO_FCALL                                      0  $12     
         18        CONCAT                                           ~13     'Speak+of+the+dog+class%3A+', $12
         19        CONCAT                                           ~14     ~13, '%0A'
         20        ECHO                                                     ~14
         21      > RETURN                                                   1

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

End of function __construct

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

End of function speak

End of class Pet.

Class Dog:
Function speak:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 7
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T8pXB
function name:  speak
number of ops:  10
compiled vars:  !0 = $what
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV_INIT                                        !0      null
   25     1      > JMPZ                                                     !0, ->7
          2    >   INIT_STATIC_METHOD_CALL                                  'speak'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $1      
          5        QM_ASSIGN                                        ~2      $1
          6      > JMP                                                      ->8
          7    >   QM_ASSIGN                                        ~2      'Woof+Woof%21'
          8    > > RETURN                                                   ~2
   35     9*     > RETURN                                                   null

End of function speak

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

End of function plays

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

End of function __construct

End of class Dog.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.18 ms | 1399 KiB | 13 Q