3v4l.org

run code in 300+ PHP versions simultaneously
<?php $variabel = "globalt scope"; function hentscope($scope) { if($scope === "getglobal") { global $variabel; } elseif($scope === "GLOBAL") { $variabel = $GLOBALS["variabel"]; } elseif($scope === "local") { $variabel = "lokalt scope"; } return $variabel; } // vi kalder så på forskellige måder echo hentscope("getglobal"); // her henter vi variabel fra det globale scope echo hentscope("GLOBAL"); // henter gennem $GLOBALS (superglobal) echo hentscope("local"); // henter variabel fra local scope (sætter egen variabel) - denne skal ikke bruges i dette tilfælde echo hentscope(""); // sucky error, der er ingen variabel i dit scope der hedder variabel ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tEDHm
function name:  (null)
number of ops:  18
compiled vars:  !0 = $variabel
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'globalt+scope'
   19     1        INIT_FCALL                                               'hentscope'
          2        SEND_VAL                                                 'getglobal'
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
   20     5        INIT_FCALL                                               'hentscope'
          6        SEND_VAL                                                 'GLOBAL'
          7        DO_FCALL                                      0  $3      
          8        ECHO                                                     $3
   21     9        INIT_FCALL                                               'hentscope'
         10        SEND_VAL                                                 'local'
         11        DO_FCALL                                      0  $4      
         12        ECHO                                                     $4
   22    13        INIT_FCALL                                               'hentscope'
         14        SEND_VAL                                                 ''
         15        DO_FCALL                                      0  $5      
         16        ECHO                                                     $5
   23    17      > RETURN                                                   1

Function hentscope:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/tEDHm
function name:  hentscope
number of ops:  16
compiled vars:  !0 = $scope, !1 = $variabel
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        IS_IDENTICAL                                             !0, 'getglobal'
          2      > JMPZ                                                     ~2, ->5
    7     3    >   BIND_GLOBAL                                              !1, 'variabel'
          4      > JMP                                                      ->14
    8     5    >   IS_IDENTICAL                                             !0, 'GLOBAL'
          6      > JMPZ                                                     ~3, ->11
    9     7    >   FETCH_R                      global              ~4      'GLOBALS'
          8        FETCH_DIM_R                                      ~5      ~4, 'variabel'
          9        ASSIGN                                                   !1, ~5
         10      > JMP                                                      ->14
   10    11    >   IS_IDENTICAL                                             !0, 'local'
         12      > JMPZ                                                     ~7, ->14
   11    13    >   ASSIGN                                                   !1, 'lokalt+scope'
   14    14    > > RETURN                                                   !1
   15    15*     > RETURN                                                   null

End of function hentscope

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.61 ms | 1403 KiB | 17 Q