3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Variable variable. $a = 'b'; $b = 'target'; var_dump($$a == $b); // Anon function with inclusion of scope. $fn = function($c) { var_dump($$c == 'target'); }; $fn($a); // I can use scope within using variable variable. $fn = fn($c) => $$c == 'target'; var_dump($fn($a)); // I can't return it though. $fn = fn($c) => $$c; var_dump($fn($a));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LrCEX
function name:  (null)
number of ops:  29
compiled vars:  !0 = $a, !1 = $b, !2 = $fn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'b'
    4     1        ASSIGN                                                   !1, 'target'
    5     2        INIT_FCALL                                               'var_dump'
          3        FETCH_R                      local               ~5      !0
          4        IS_EQUAL                                         ~6      !1, ~5
          5        SEND_VAL                                                 ~6
          6        DO_ICALL                                                 
    8     7        DECLARE_LAMBDA_FUNCTION                          ~8      [0]
          8        ASSIGN                                                   !2, ~8
   11     9        INIT_DYNAMIC_CALL                                        !2
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
   14    12        DECLARE_LAMBDA_FUNCTION                          ~11     [1]
         13        ASSIGN                                                   !2, ~11
   15    14        INIT_FCALL                                               'var_dump'
         15        INIT_DYNAMIC_CALL                                        !2
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0  $13     
         18        SEND_VAR                                                 $13
         19        DO_ICALL                                                 
   18    20        DECLARE_LAMBDA_FUNCTION                          ~15     [2]
         21        ASSIGN                                                   !2, ~15
   19    22        INIT_FCALL                                               'var_dump'
         23        INIT_DYNAMIC_CALL                                        !2
         24        SEND_VAR_EX                                              !0
         25        DO_FCALL                                      0  $17     
         26        SEND_VAR                                                 $17
         27        DO_ICALL                                                 
         28      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LrCEX
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'var_dump'
          2        FETCH_R                      local               ~1      !0
          3        IS_EQUAL                                         ~2      ~1, 'target'
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                                 
   10     6      > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LrCEX
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        FETCH_R                      local               ~1      !0
          2        IS_EQUAL                                         ~2      ~1, 'target'
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LrCEX
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        FETCH_R                      local               ~1      !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of Dynamic Function 2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.11 ms | 1005 KiB | 14 Q