3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User{ const GIVEN = 1; // class constants can't be labeled static nor assigned visibility public $a=2; public static $b=3; public function me(){ echo "print me"; } public static function you() { echo "print you"; } } class myUser extends User { } // Are properties and methods instantiated to an object of a class, & are they accessible? $object1= new User(); // uncomment this line with each of the following lines individually //echo $object1->GIVEN . ""; // yields nothing //echo $object1->GIVE . ""; // deliberately misnamed, still yields nothing //echo $object1->User::GIVEN . ""; // yields nothing //echo $object1->a . ""; // yields 2 //echo $object1->b . ""; // yields nothing //echo $object1->me() . ""; // yields print me //echo $object1->you() . ""; // yields print you // Are properties and methods instantiated to an object of a child class, & are accessible? //$object2= new myUser(); // uncomment this line with each of the following lines individually //echo $object2->GIVEN . ""; // yields nothing //echo $object2->a . ""; // yields 2 //echo $object2->b . ""; // yields nothing //echo $object2->me() . ""; // yields print me //echo $object2->you() . ""; // yields print you // Are the properties and methods accessible directly in the class? //echo User::GIVEN . ""; // yields 1 //echo User::$a . ""; // yields fatal error since it is not static //echo User::$b . ""; // yields 3 //echo User::me() . ""; // yields print me //echo User::you() . ""; // yields print you // Are the properties and methods copied to the child class and are they accessible? //echo myUser::GIVEN . ""; // yields 1 //echo myUser::$a . ""; // yields fatal error since it is not static echo myUser::$b . ""; // yields 3 //echo myUser::me() . ""; // yields print me //echo myUser::you() . ""; // yields print you
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ceTeD
function name:  (null)
number of ops:  7
compiled vars:  !0 = $object1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $1      'User'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   46     3        FETCH_STATIC_PROP_R          global lock         ~4      'b'
          4        CONCAT                                           ~5      ~4, ''
          5        ECHO                                                     ~5
   48     6      > RETURN                                                   1

Class User:
Function me:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ceTeD
function name:  me
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ECHO                                                     'print+me'
    9     1      > RETURN                                                   null

End of function me

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

End of function you

End of class User.

Class myUser:
Function me:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ceTeD
function name:  me
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ECHO                                                     'print+me'
    9     1      > RETURN                                                   null

End of function me

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

End of function you

End of class myUser.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.84 ms | 1399 KiB | 13 Q