3v4l.org

run code in 300+ PHP versions simultaneously
<?php //var_dump(get_defined_constants(true)['Core']); class Foo { const ERR_SOME_CONST = 6001; const ERR_SOME_OTHER_CONST = 5001; function bar() { $x = 6001; $fooClass = new ReflectionClass ( 'Foo' ); $constants = $fooClass->getConstants(); $constants = get_defined_constants(); $constName = null; foreach ( $constants as $name => $value ) { if ( $value == $x ) { $constName = $name; break; } } echo $constName; } } echo (new Foo)->bar();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Gu52
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   NEW                                              $0      'Foo'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $0, 'bar'
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Class Foo:
Function bar:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 20
Branch analysis from position: 20
filename:       /in/2Gu52
function name:  bar
number of ops:  23
compiled vars:  !0 = $x, !1 = $fooClass, !2 = $constants, !3 = $constName, !4 = $value, !5 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, 6001
   11     1        NEW                                              $7      'ReflectionClass'
          2        SEND_VAL_EX                                              'Foo'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $7
   12     5        INIT_METHOD_CALL                                         !1, 'getConstants'
          6        DO_FCALL                                      0  $10     
          7        ASSIGN                                                   !2, $10
   14     8        INIT_FCALL                                               'get_defined_constants'
          9        DO_ICALL                                         $12     
         10        ASSIGN                                                   !2, $12
   16    11        ASSIGN                                                   !3, null
   17    12      > FE_RESET_R                                       $15     !2, ->20
         13    > > FE_FETCH_R                                       ~16     $15, !4, ->20
         14    >   ASSIGN                                                   !5, ~16
   19    15        IS_EQUAL                                                 !4, !0
         16      > JMPZ                                                     ~18, ->19
   21    17    >   ASSIGN                                                   !3, !5
   22    18      > JMP                                                      ->20
   17    19    > > JMP                                                      ->13
         20    >   FE_FREE                                                  $15
   26    21        ECHO                                                     !3
   27    22      > RETURN                                                   null

End of function bar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.11 ms | 1396 KiB | 15 Q