3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $foobar = 'Foo'; public function test() { echo $this->foobar . "\n"; } } class Bar extends Foo { public $foobar = 'Bar'; } $a = new Foo(); $b = new Bar(); echo "use of test() method\n"; $a->test(); $b->test(); echo "instanceof Foo\n"; var_dump($a instanceof Foo); // TRUE var_dump($b instanceof Foo); // TRUE echo "instanceof Bar\n"; var_dump($a instanceof Bar); // FALSE var_dump($b instanceof Bar); // TRUE echo "subclass of Foo\n"; var_dump(is_subclass_of($a, 'Foo')); // FALSE var_dump(is_subclass_of($b, 'Foo')); // TRUE echo "subclass of Bar\n"; var_dump(is_subclass_of($a, 'Bar')); // FALSE var_dump(is_subclass_of($b, 'Bar')); // FALSE
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oCFs8
function name:  (null)
number of ops:  60
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   20     3        NEW                                              $5      'Bar'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   22     6        ECHO                                                     'use+of+test%28%29+method%0A'
   23     7        INIT_METHOD_CALL                                         !0, 'test'
          8        DO_FCALL                                      0          
   24     9        INIT_METHOD_CALL                                         !1, 'test'
         10        DO_FCALL                                      0          
   26    11        ECHO                                                     'instanceof+Foo%0A'
   27    12        INIT_FCALL                                               'var_dump'
         13        INSTANCEOF                                       ~10     !0, 'Foo'
         14        SEND_VAL                                                 ~10
         15        DO_ICALL                                                 
   28    16        INIT_FCALL                                               'var_dump'
         17        INSTANCEOF                                       ~12     !1, 'Foo'
         18        SEND_VAL                                                 ~12
         19        DO_ICALL                                                 
   30    20        ECHO                                                     'instanceof+Bar%0A'
   31    21        INIT_FCALL                                               'var_dump'
         22        INSTANCEOF                                       ~14     !0, 'Bar'
         23        SEND_VAL                                                 ~14
         24        DO_ICALL                                                 
   32    25        INIT_FCALL                                               'var_dump'
         26        INSTANCEOF                                       ~16     !1, 'Bar'
         27        SEND_VAL                                                 ~16
         28        DO_ICALL                                                 
   34    29        ECHO                                                     'subclass+of+Foo%0A'
   35    30        INIT_FCALL                                               'var_dump'
         31        INIT_FCALL                                               'is_subclass_of'
         32        SEND_VAR                                                 !0
         33        SEND_VAL                                                 'Foo'
         34        DO_ICALL                                         $18     
         35        SEND_VAR                                                 $18
         36        DO_ICALL                                                 
   36    37        INIT_FCALL                                               'var_dump'
         38        INIT_FCALL                                               'is_subclass_of'
         39        SEND_VAR                                                 !1
         40        SEND_VAL                                                 'Foo'
         41        DO_ICALL                                         $20     
         42        SEND_VAR                                                 $20
         43        DO_ICALL                                                 
   38    44        ECHO                                                     'subclass+of+Bar%0A'
   39    45        INIT_FCALL                                               'var_dump'
         46        INIT_FCALL                                               'is_subclass_of'
         47        SEND_VAR                                                 !0
         48        SEND_VAL                                                 'Bar'
         49        DO_ICALL                                         $22     
         50        SEND_VAR                                                 $22
         51        DO_ICALL                                                 
   40    52        INIT_FCALL                                               'var_dump'
         53        INIT_FCALL                                               'is_subclass_of'
         54        SEND_VAR                                                 !1
         55        SEND_VAL                                                 'Bar'
         56        DO_ICALL                                         $24     
         57        SEND_VAR                                                 $24
         58        DO_ICALL                                                 
         59      > RETURN                                                   1

Class Foo:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oCFs8
function name:  test
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_OBJ_R                                      ~0      'foobar'
          1        CONCAT                                           ~1      ~0, '%0A'
          2        ECHO                                                     ~1
    9     3      > RETURN                                                   null

End of function test

End of class Foo.

Class Bar:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oCFs8
function name:  test
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_OBJ_R                                      ~0      'foobar'
          1        CONCAT                                           ~1      ~0, '%0A'
          2        ECHO                                                     ~1
    9     3      > RETURN                                                   null

End of function test

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.01 ms | 1400 KiB | 17 Q