3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Correct { protected $fields = array( 'one' => 'foo', 'two' => 'bar' ); public function __get($value) { $method = 'get' . ucfirst($value); if(method_exists($this, $method)) { return $this->$method(); } return $this->fields[$value]; } public function getOne() { return strtoupper($this->fields['one']); } } $cor = new Correct; echo $cor->one; echo $cor->two;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pWoLk
function name:  (null)
number of ops:  8
compiled vars:  !0 = $cor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $1      'Correct'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   22     3        FETCH_OBJ_R                                      ~4      !0, 'one'
          4        ECHO                                                     ~4
   23     5        FETCH_OBJ_R                                      ~5      !0, 'two'
          6        ECHO                                                     ~5
          7      > RETURN                                                   1

Class Correct:
Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pWoLk
function name:  __get
number of ops:  19
compiled vars:  !0 = $value, !1 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'ucfirst'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        CONCAT                                           ~3      'get', $2
          5        ASSIGN                                                   !1, ~3
   10     6        INIT_FCALL                                               'method_exists'
          7        FETCH_THIS                                       ~5      
          8        SEND_VAL                                                 ~5
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $6      
         11      > JMPZ                                                     $6, ->15
   11    12    >   INIT_METHOD_CALL                                         !1
         13        DO_FCALL                                      0  $7      
         14      > RETURN                                                   $7
   13    15    >   FETCH_OBJ_R                                      ~8      'fields'
         16        FETCH_DIM_R                                      ~9      ~8, !0
         17      > RETURN                                                   ~9
   14    18*     > RETURN                                                   null

End of function __get

Function getone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pWoLk
function name:  getOne
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'strtoupper'
          1        FETCH_OBJ_R                                      ~0      'fields'
          2        FETCH_DIM_R                                      ~1      ~0, 'one'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5      > RETURN                                                   $2
   18     6*     > RETURN                                                   null

End of function getone

End of class Correct.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.76 ms | 1400 KiB | 19 Q