3v4l.org

run code in 500+ PHP versions simultaneously
<?php final class Constants { public function __get($constName) { // Null for non-defined "constants" $val = null; switch($constName){ case 'FOO': $val = 'MY CONSTANT UNCHANGEABLE VALUE'; break; case 'BAR': $val = 'MY OTHER CONSTANT VALUE'; break; } return $val; } public function __set($key, $value) { throw new Exception('A runtime modification of constant values is not allowed.'); } } $c = new Constants; echo $c->FOO; $c->FOO = 'Hello World';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UgEEm
function name:  (null)
number of ops:  8
compiled vars:  !0 = $c
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   NEW                                                  $1      'Constants'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $1
   28     3        FETCH_OBJ_R                                          ~4      !0, 'FOO'
          4        ECHO                                                         ~4
   29     5        ASSIGN_OBJ                                                   !0, 'FOO'
          6        OP_DATA                                                      'Hello+World'
          7      > RETURN                                                       1

Class Constants:
Function __get:
Finding entry points
Branch analysis from position: 0
4 jumps found. (Code = 188) Position 1 = 8, Position 2 = 10, Position 3 = 12, Position 4 = 3
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 12
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 10
Branch analysis from position: 8
filename:       /in/UgEEm
function name:  __get
number of ops:  14
compiled vars:  !0 = $constName, !1 = $val
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
    8     1        ASSIGN                                                       !1, null
   10     2      > SWITCH_STRING                                                !0, [ 'FOO':->8, 'BAR':->10, ], ->12
   11     3    >   IS_EQUAL                                                     !0, 'FOO'
          4      > JMPNZ                                                        ~3, ->8
   14     5    >   IS_EQUAL                                                     !0, 'BAR'
          6      > JMPNZ                                                        ~3, ->10
          7    > > JMP                                                          ->12
   12     8    >   ASSIGN                                                       !1, 'MY+CONSTANT+UNCHANGEABLE+VALUE'
   13     9      > JMP                                                          ->12
   15    10    >   ASSIGN                                                       !1, 'MY+OTHER+CONSTANT+VALUE'
   16    11      > JMP                                                          ->12
   19    12    > > RETURN                                                       !1
   20    13*     > RETURN                                                       null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/UgEEm
function name:  __set
number of ops:  7
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   23     2        NEW                                                  $2      'Exception'
          3        SEND_VAL_EX                                                  'A+runtime+modification+of+constant+values+is+not+allowed.'
          4        DO_FCALL                                          0          
          5      > THROW                                             0          $2
   24     6*     > RETURN                                                       null

End of function __set

End of class Constants.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
208.7 ms | 3168 KiB | 13 Q