3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ParentClass{ const KONSTANTA = 'ParentClass'; public function __construct(){ echo self::KONSTANTA.'<br/>';//Memanggil konstanta dari internal class } public function printKonstanta(){ echo 'Class : '.self::KONSTANTA.'<br/>';//Memanggil konstanta dari internal class } } class ChildClass extends ParentClass{ private $privateProperty; const KONSTANTA = 'ChildClass';//Overriding property public function __construct(){ parent::__construct();//Memanggil konstruktor ParentClass echo ChildClass::KONSTANTA.'<br/>';//Bisa juga dipanggil dengan cara seperti ini } public function printPrivate(){ echo 'Property : '.$this->privateProperty.'<br/>';//$this digunakan untuk memanggil properti atau method internal } } class Child2Class extends ParentClass{ public static $STATIC; public function __construct(){ echo self::KONSTANTA.'<br/>';//ParentClass mewariskan KONSTANTA } public static function printLangsung(){ echo 'Bisa diprint langsung tanpa instansiasi<br/>'; } } $a = new ParentClass(); $a::printKonstanta();//Print Konstanta menggunakan Scope Resolution pada Object $b = new ChildClass(); $b->printPrivate(); Child2Class::$STATIC = 'Isi variable static'; Child2Class::printLangsung(); echo Child2Class::$STATIC;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MGKZl
function name:  (null)
number of ops:  18
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   NEW                                              $2      'ParentClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   39     3        FETCH_CLASS                                   0  $5      !0
          4        INIT_STATIC_METHOD_CALL                                  $5, 'printKonstanta'
          5        DO_FCALL                                      0          
   40     6        NEW                                              $7      'ChildClass'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $7
   41     9        INIT_METHOD_CALL                                         !1, 'printPrivate'
         10        DO_FCALL                                      0          
   42    11        ASSIGN_STATIC_PROP                                       'STATIC', 'Child2Class'
         12        OP_DATA                                                  'Isi+variable+static'
   43    13        INIT_STATIC_METHOD_CALL                                  'Child2Class', 'printLangsung'
         14        DO_FCALL                                      0          
   44    15        FETCH_STATIC_PROP_R          unknown             ~13     'STATIC'
         16        ECHO                                                     ~13
         17      > RETURN                                                   1

Class ParentClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MGKZl
function name:  __construct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                     'ParentClass%3Cbr%2F%3E'
    6     1      > RETURN                                                   null

End of function __construct

Function printkonstanta:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MGKZl
function name:  printKonstanta
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ECHO                                                     'Class+%3A+ParentClass%3Cbr%2F%3E'
   10     1      > RETURN                                                   null

End of function printkonstanta

End of class ParentClass.

Class ChildClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MGKZl
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_STATIC_METHOD_CALL                                  
          1        DO_FCALL                                      0          
   19     2        ECHO                                                     'ChildClass%3Cbr%2F%3E'
   20     3      > RETURN                                                   null

End of function __construct

Function printprivate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MGKZl
function name:  printPrivate
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   FETCH_OBJ_R                                      ~0      'privateProperty'
          1        CONCAT                                           ~1      'Property+%3A+', ~0
          2        CONCAT                                           ~2      ~1, '%3Cbr%2F%3E'
          3        ECHO                                                     ~2
   24     4      > RETURN                                                   null

End of function printprivate

Function printkonstanta:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MGKZl
function name:  printKonstanta
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ECHO                                                     'Class+%3A+ParentClass%3Cbr%2F%3E'
   10     1      > RETURN                                                   null

End of function printkonstanta

End of class ChildClass.

Class Child2Class:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MGKZl
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   FETCH_CLASS_CONSTANT                             ~0      'KONSTANTA'
          1        CONCAT                                           ~1      ~0, '%3Cbr%2F%3E'
          2        ECHO                                                     ~1
   32     3      > RETURN                                                   null

End of function __construct

Function printlangsung:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MGKZl
function name:  printLangsung
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   ECHO                                                     'Bisa+diprint+langsung+tanpa+instansiasi%3Cbr%2F%3E'
   36     1      > RETURN                                                   null

End of function printlangsung

Function printkonstanta:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MGKZl
function name:  printKonstanta
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ECHO                                                     'Class+%3A+ParentClass%3Cbr%2F%3E'
   10     1      > RETURN                                                   null

End of function printkonstanta

End of class Child2Class.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.01 ms | 1399 KiB | 13 Q