3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getConstantName($category, $constantNumber) { foreach (get_defined_constants() as $key => $value) { if (strlen($key) > strlen($category)) { if (substr($key, 0, strlen($category)) === $category) { if ($value === $constantNumber) { return $key; } return null; } } } } var_dump( getConstantName('IMAGE', 1) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Q4GKn
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'getconstantname'
          2        SEND_VAL                                                 'IMAGE'
          3        SEND_VAL                                                 1
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function getconstantname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 26
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 26
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 25
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/Q4GKn
function name:  getConstantName
number of ops:  28
compiled vars:  !0 = $category, !1 = $constantNumber, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'get_defined_constants'
          3        DO_ICALL                                         $4      
          4      > FE_RESET_R                                       $5      $4, ->26
          5    > > FE_FETCH_R                                       ~6      $5, !2, ->26
          6    >   ASSIGN                                                   !3, ~6
    6     7        STRLEN                                           ~8      !3
          8        STRLEN                                           ~9      !0
          9        IS_SMALLER                                               ~9, ~8
         10      > JMPZ                                                     ~10, ->25
    7    11    >   INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !3
         13        SEND_VAL                                                 0
         14        STRLEN                                           ~11     !0
         15        SEND_VAL                                                 ~11
         16        DO_ICALL                                         $12     
         17        IS_IDENTICAL                                             !0, $12
         18      > JMPZ                                                     ~13, ->25
    8    19    >   IS_IDENTICAL                                             !2, !1
         20      > JMPZ                                                     ~14, ->23
    9    21    >   FE_FREE                                                  $5
         22      > RETURN                                                   !3
   12    23    >   FE_FREE                                                  $5
         24      > RETURN                                                   null
    5    25    > > JMP                                                      ->5
         26    >   FE_FREE                                                  $5
   16    27      > RETURN                                                   null

End of function getconstantname

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.33 ms | 1394 KiB | 20 Q