3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private int $number = 5; public function getNumber(): int { return $this->number; } } $fieldName = "number"; $fieldNameFirstChar = mb_strtoupper(mb_substr($fieldName, 0, 1)); $fieldNameLastChars = mb_substr($fieldName, 1); $fieldName = "get" . $fieldNameFirstChar . $fieldNameLastChars; $test = new Test(); print_r($test->$fieldName());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MpibO
function name:  (null)
number of ops:  27
compiled vars:  !0 = $fieldName, !1 = $fieldNameFirstChar, !2 = $fieldNameLastChars, !3 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, 'number'
   15     1        INIT_FCALL                                               'mb_strtoupper'
          2        INIT_FCALL                                               'mb_substr'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 1
          6        DO_ICALL                                         $5      
          7        SEND_VAR                                                 $5
          8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !1, $6
   16    10        INIT_FCALL                                               'mb_substr'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 1
         13        DO_ICALL                                         $8      
         14        ASSIGN                                                   !2, $8
   17    15        CONCAT                                           ~10     'get', !1
         16        CONCAT                                           ~11     ~10, !2
         17        ASSIGN                                                   !0, ~11
   19    18        NEW                                              $13     'Test'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !3, $13
   20    21        INIT_FCALL                                               'print_r'
         22        INIT_METHOD_CALL                                         !3, !0
         23        DO_FCALL                                      0  $16     
         24        SEND_VAR                                                 $16
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Class Test:
Function getnumber:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MpibO
function name:  getNumber
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                      ~0      'number'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   10     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getnumber

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.82 ms | 1001 KiB | 16 Q