3v4l.org

run code in 500+ PHP versions simultaneously
<?php function test($var, array $G, array $P) { if (empty($var)) { return; } if (isset($P[$var])) { $value = $P[$var]; } elseif (isset($G[$var])) { $value = $G[$var]; } else { $value = null; } return $value; } function test2($var, array $G, array $P) { return $P[$var] ?? $G[$var] ?? null; } $G = ['a' => 'A', 'b' => '']; $P = ['b' => 'B']; print test('a', $G, $P) . PHP_EOL; print test('b', $G, $P) . PHP_EOL; print test('', $G, $P) . PHP_EOL; print '-----' . PHP_EOL; print test2('a', $G, $P) . PHP_EOL; print test2('b', $G, $P) . PHP_EOL; print test2('', $G, $P) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/spVZH
function name:  (null)
number of ops:  46
compiled vars:  !0 = $G, !1 = $P
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                       !0, <array>
   23     1        ASSIGN                                                       !1, <array>
   25     2        INIT_FCALL                                                   'test'
          3        SEND_VAL                                                     'a'
          4        SEND_VAR                                                     !0
          5        SEND_VAR                                                     !1
          6        DO_FCALL                                          0  $4      
          7        CONCAT                                               ~5      $4, '%0A'
          8        ECHO                                                         ~5
   26     9        INIT_FCALL                                                   'test'
         10        SEND_VAL                                                     'b'
         11        SEND_VAR                                                     !0
         12        SEND_VAR                                                     !1
         13        DO_FCALL                                          0  $6      
         14        CONCAT                                               ~7      $6, '%0A'
         15        ECHO                                                         ~7
   27    16        INIT_FCALL                                                   'test'
         17        SEND_VAL                                                     ''
         18        SEND_VAR                                                     !0
         19        SEND_VAR                                                     !1
         20        DO_FCALL                                          0  $8      
         21        CONCAT                                               ~9      $8, '%0A'
         22        ECHO                                                         ~9
   29    23        ECHO                                                         '-----%0A'
   31    24        INIT_FCALL                                                   'test2'
         25        SEND_VAL                                                     'a'
         26        SEND_VAR                                                     !0
         27        SEND_VAR                                                     !1
         28        DO_FCALL                                          0  $10     
         29        CONCAT                                               ~11     $10, '%0A'
         30        ECHO                                                         ~11
   32    31        INIT_FCALL                                                   'test2'
         32        SEND_VAL                                                     'b'
         33        SEND_VAR                                                     !0
         34        SEND_VAR                                                     !1
         35        DO_FCALL                                          0  $12     
         36        CONCAT                                               ~13     $12, '%0A'
         37        ECHO                                                         ~13
   33    38        INIT_FCALL                                                   'test2'
         39        SEND_VAL                                                     ''
         40        SEND_VAR                                                     !0
         41        SEND_VAR                                                     !1
         42        DO_FCALL                                          0  $14     
         43        CONCAT                                               ~15     $14, '%0A'
         44        ECHO                                                         ~15
   34    45      > RETURN                                                       1

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/spVZH
function name:  test
number of ops:  19
compiled vars:  !0 = $var, !1 = $G, !2 = $P, !3 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
    4     3        ISSET_ISEMPTY_CV                                             !0
          4      > JMPZ                                                         ~4, ->6
    5     5    > > RETURN                                                       null
    7     6    >   ISSET_ISEMPTY_DIM_OBJ                             0          !2, !0
          7      > JMPZ                                                         ~5, ->11
    8     8    >   FETCH_DIM_R                                          ~6      !2, !0
          9        ASSIGN                                                       !3, ~6
    7    10      > JMP                                                          ->17
    9    11    >   ISSET_ISEMPTY_DIM_OBJ                             0          !1, !0
         12      > JMPZ                                                         ~8, ->16
   10    13    >   FETCH_DIM_R                                          ~9      !1, !0
         14        ASSIGN                                                       !3, ~9
    9    15      > JMP                                                          ->17
   12    16    >   ASSIGN                                                       !3, null
   14    17    > > RETURN                                                       !3
   15    18*     > RETURN                                                       null

End of function test

Function test2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/spVZH
function name:  test2
number of ops:  11
compiled vars:  !0 = $var, !1 = $G, !2 = $P
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   18     3        FETCH_DIM_IS                                         ~3      !2, !0
          4        COALESCE                                             ~4      ~3
          5        FETCH_DIM_IS                                         ~5      !1, !0
          6        COALESCE                                             ~6      ~5
          7        QM_ASSIGN                                            ~6      null
          8        QM_ASSIGN                                            ~4      ~6
          9      > RETURN                                                       ~4
   19    10*     > RETURN                                                       null

End of function test2

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
154.69 ms | 504 KiB | 13 Q