3v4l.org

run code in 300+ PHP versions simultaneously
<?php $facts = []; $facts['A'] = true; $facts['B'] = false; $test = '(A || B);'; $ruleExecutor = function ($_rule) use ($facts) { $_condition = preg_replace('/(\w+)/', '$$1', $_rule); //(A || B) => ($A || $B) extract($facts); var_dump($A); var_dump($B); unset($facts); var_dump($_condition); return eval($_condition); }; var_dump($ruleExecutor($test)); var_dump($facts); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W3AjN
function name:  (null)
number of ops:  19
compiled vars:  !0 = $facts, !1 = $test, !2 = $ruleExecutor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN_DIM                                               !0, 'A'
          2        OP_DATA                                                  <true>
    5     3        ASSIGN_DIM                                               !0, 'B'
          4        OP_DATA                                                  <false>
    7     5        ASSIGN                                                   !1, '%28A+%7C%7C+B%29%3B'
    9     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FW3AjN%3A9%240'
          7        BIND_LEXICAL                                             ~7, !0
          8        ASSIGN                                                   !2, ~7
   19     9        INIT_FCALL                                               'var_dump'
         10        INIT_DYNAMIC_CALL                                        !2
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0  $9      
         13        SEND_VAR                                                 $9
         14        DO_ICALL                                                 
   20    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                                 
   22    18      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FW3AjN%3A9%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W3AjN
function name:  {closure}
number of ops:  24
compiled vars:  !0 = $_rule, !1 = $facts, !2 = $_condition, !3 = $A, !4 = $B
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   10     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAL                                                 '%2F%28%5Cw%2B%29%2F'
          4        SEND_VAL                                                 '%24%241'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !2, $5
   11     8        INIT_FCALL                                               'extract'
          9        SEND_REF                                                 !1
         10        DO_ICALL                                                 
   12    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                                 
   13    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                                 
   14    17        UNSET_CV                                                 !1
   15    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
   16    21        INCLUDE_OR_EVAL                                  $11     !2, EVAL
         22      > RETURN                                                   $11
   17    23*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FW3AjN%3A9%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.79 ms | 1400 KiB | 19 Q