3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $one = ''; public $two = ''; //Constructor public function __construct() { //Constructor } //print variable one public function echoOne() { echo $this->one."\n"; } //print variable two public function echoTwo() { echo $this->two."\n"; } } //Instantiate the object $a = new A(); //Instantiate the reflection object $reflector = new ReflectionClass('A'); //Now get all the properties from class A in to $properties array $properties = $reflector->getProperties(); $i =1; //Now go through the $properties array and populate each property foreach($properties as $property) { //Populating properties $a->{$property->getName()}=$i; //Invoking the method to print what was populated $a->{"echo".ucfirst($property->getName())}()."\n"; $i++; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 29
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 29
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/lC4FQ
function name:  (null)
number of ops:  31
compiled vars:  !0 = $a, !1 = $reflector, !2 = $properties, !3 = $i, !4 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $5      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
   30     3        NEW                                              $8      'ReflectionClass'
          4        SEND_VAL_EX                                              'A'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $8
   33     7        INIT_METHOD_CALL                                         !1, 'getProperties'
          8        DO_FCALL                                      0  $11     
          9        ASSIGN                                                   !2, $11
   35    10        ASSIGN                                                   !3, 1
   37    11      > FE_RESET_R                                       $14     !2, ->29
         12    > > FE_FETCH_R                                               $14, !4, ->29
   40    13    >   INIT_METHOD_CALL                                         !4, 'getName'
         14        DO_FCALL                                      0  $15     
         15        ASSIGN_OBJ                                               !0, $15
         16        OP_DATA                                                  !3
   42    17        INIT_FCALL                                               'ucfirst'
         18        INIT_METHOD_CALL                                         !4, 'getName'
         19        DO_FCALL                                      0  $17     
         20        SEND_VAR                                                 $17
         21        DO_ICALL                                         $18     
         22        CONCAT                                           ~19     'echo', $18
         23        INIT_METHOD_CALL                                         !0, ~19
         24        DO_FCALL                                      0  $20     
         25        CONCAT                                           ~21     $20, '%0A'
         26        FREE                                                     ~21
   44    27        PRE_INC                                                  !3
   37    28      > JMP                                                      ->12
         29    >   FE_FREE                                                  $14
   45    30      > RETURN                                                   1

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

End of function __construct

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

End of function echoone

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

End of function echotwo

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.73 ms | 1405 KiB | 15 Q