3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Expressions { // Prerequisites for examples below public $a = 1; public static $b = 3; function bar() {} static function baz() {} function foo() { // Prerequisites for examples below $a = 1; $b = 2; $x = [1, 2]; file_put_contents('/tmp/a.php', ''); // Examples based on php-parser expression types // Using as few variables within the expressions themselves as the parser allows, to avoid false-positives static $arrowFunction = fn() => 1; static $assign = ($a = 1); static $assignOpAdd = ($a += 1); static $assignOpAnd = ($a &= 1); static $assignOpConcat = ($a .= "b"); static $assignOpDiv = ($a /= 2); static $assignRef = ($a =& $b); static $castInt = (int)"1"; static $clone = clone (new stdClass()); static $closure = function () { return 1; }; static $closureUse = function () use ($x) {}; static $empty = empty(1); static $encapsed = "Value: $a"; static $errorSuppress = @new stdClass(); static $eval = eval('1+1;'); static $funcCall = strlen('x'); static $include = include '/tmp/a.php'; static $instanceof = new stdClass() instanceof self; static $isset = isset($x); static $list = [[$a, $b] = [1, 2]]; static $match = match (1) {1 => 'a', default => 'b'}; static $methodCall = (new Expressions())->bar(); static $nullsafeMethodCall = (new Expressions())?->bar(); static $postInc = $a++; static $print = print ''; static $shellExec = `whoami`; // expected warning due to sandbox environment static $staticCall = self::baz(); static $staticPropertyFetch = self::$b; static $variable = $a; // These are invalid but give a different error static $nullsafePropertyFetch = (new Expressions())?->a; static $propertyFetch = (new Expressions())->a; } } $expr = new Expressions(); $expr->foo();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NLM69
function name:  (null)
number of ops:  6
compiled vars:  !0 = $expr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   NEW                                              $1      'Expressions'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   58     3        INIT_METHOD_CALL                                         !0, 'foo'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Class Expressions:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NLM69
function name:  bar
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E > > RETURN                                                   null

End of function bar

Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NLM69
function name:  baz
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                   null

End of function baz

Function foo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 81, Position 2 = 82
Branch analysis from position: 81
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 86
Branch analysis from position: 86
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 82
1 jumps found. (Code = 42) Position 1 = 86
Branch analysis from position: 86
filename:       /in/NLM69
function name:  foo
number of ops:  132
compiled vars:  !0 = $a, !1 = $b, !2 = $x, !3 = $arrowFunction, !4 = $assign, !5 = $assignOpAdd, !6 = $assignOpAnd, !7 = $assignOpConcat, !8 = $assignOpDiv, !9 = $assignRef, !10 = $castInt, !11 = $clone, !12 = $closure, !13 = $closureUse, !14 = $empty, !15 = $encapsed, !16 = $errorSuppress, !17 = $eval, !18 = $funcCall, !19 = $include, !20 = $instanceof, !21 = $isset, !22 = $list, !23 = $match, !24 = $methodCall, !25 = $nullsafeMethodCall, !26 = $postInc, !27 = $print, !28 = $shellExec, !29 = $staticCall, !30 = $staticPropertyFetch, !31 = $variable, !32 = $nullsafePropertyFetch, !33 = $propertyFetch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, 1
   15     1        ASSIGN                                                   !1, 2
   16     2        ASSIGN                                                   !2, <array>
   17     3        INIT_FCALL                                               'file_put_contents'
          4        SEND_VAL                                                 '%2Ftmp%2Fa.php'
          5        SEND_VAL                                                 ''
          6        DO_ICALL                                                 
   21     7        ZEND_BIND_INIT_STATIC_OR_JMP                             !3
          8        DECLARE_LAMBDA_FUNCTION                          ~38     [0]
          9        BIND_STATIC                                              !3, ~38
   22    10        ZEND_BIND_INIT_STATIC_OR_JMP                             !4
         11        ASSIGN                                           ~39     !0, 1
         12        BIND_STATIC                                              !4, ~39
   23    13        ZEND_BIND_INIT_STATIC_OR_JMP                             !5
         14        ASSIGN_OP                                     1  ~40     !0, 1
         15        BIND_STATIC                                              !5, ~40
   24    16        ZEND_BIND_INIT_STATIC_OR_JMP                             !6
         17        ASSIGN_OP                                    10  ~41     !0, 1
         18        BIND_STATIC                                              !6, ~41
   25    19        ZEND_BIND_INIT_STATIC_OR_JMP                             !7
         20        ASSIGN_OP                                     8  ~42     !0, 'b'
         21        BIND_STATIC                                              !7, ~42
   26    22        ZEND_BIND_INIT_STATIC_OR_JMP                             !8
         23        ASSIGN_OP                                     4  ~43     !0, 2
         24        BIND_STATIC                                              !8, ~43
   27    25        ZEND_BIND_INIT_STATIC_OR_JMP                             !9
         26        ASSIGN_REF                                       $44     !0, !1
         27        BIND_STATIC                                              !9, $44
   28    28        ZEND_BIND_INIT_STATIC_OR_JMP                             !10
         29        CAST                                          4  ~45     '1'
         30        BIND_STATIC                                              !10, ~45
   29    31        ZEND_BIND_INIT_STATIC_OR_JMP                             !11
         32        NEW                                              $46     'stdClass'
         33        DO_FCALL                                      0          
         34        CLONE                                            ~48     $46
         35        BIND_STATIC                                              !11, ~48
   30    36        ZEND_BIND_INIT_STATIC_OR_JMP                             !12
         37        DECLARE_LAMBDA_FUNCTION                          ~49     [1]
         38        BIND_STATIC                                              !12, ~49
   31    39        ZEND_BIND_INIT_STATIC_OR_JMP                             !13
         40        DECLARE_LAMBDA_FUNCTION                          ~50     [2]
         41        BIND_LEXICAL                                             ~50, !2
         42        BIND_STATIC                                              !13, ~50
   32    43        ZEND_BIND_INIT_STATIC_OR_JMP                             !14
         44        BIND_STATIC                                              !14, <false>
   33    45        ZEND_BIND_INIT_STATIC_OR_JMP                             !15
         46        NOP                                                      
         47        FAST_CONCAT                                      ~51     'Value%3A+', !0
         48        BIND_STATIC                                              !15, ~51
   34    49        ZEND_BIND_INIT_STATIC_OR_JMP                             !16
         50        BEGIN_SILENCE                                    ~52     
         51        NEW                                              $53     'stdClass'
         52        DO_FCALL                                      0          
         53        END_SILENCE                                              ~52
         54        BIND_STATIC                                              !16, $53
   35    55        ZEND_BIND_INIT_STATIC_OR_JMP                             !17
         56        INCLUDE_OR_EVAL                                  $55     '1%2B1%3B', EVAL
         57        BIND_STATIC                                              !17, $55
   36    58        ZEND_BIND_INIT_STATIC_OR_JMP                             !18
         59        BIND_STATIC                                              !18, 1
   37    60        ZEND_BIND_INIT_STATIC_OR_JMP                             !19
         61        INCLUDE_OR_EVAL                                  $56     '%2Ftmp%2Fa.php', INCLUDE
         62        BIND_STATIC                                              !19, $56
   38    63        ZEND_BIND_INIT_STATIC_OR_JMP                             !20
         64        NEW                                              $57     'stdClass'
         65        DO_FCALL                                      0          
         66        INSTANCEOF                                       ~59     $57
         67        BIND_STATIC                                              !20, ~59
   39    68        ZEND_BIND_INIT_STATIC_OR_JMP                             !21
         69        ISSET_ISEMPTY_CV                                 ~60     !2
         70        BIND_STATIC                                              !21, ~60
   40    71        ZEND_BIND_INIT_STATIC_OR_JMP                             !22
         72        FETCH_LIST_R                                     $61     <array>, 0
         73        ASSIGN                                                   !0, $61
         74        FETCH_LIST_R                                     $63     <array>, 1
         75        ASSIGN                                                   !1, $63
         76        INIT_ARRAY                                       ~65     <array>
         77        BIND_STATIC                                              !22, ~65
   41    78        ZEND_BIND_INIT_STATIC_OR_JMP                             !23
         79        IS_IDENTICAL                                             1, 1
         80      > JMPNZ                                                    ~66, ->82
         81    > > JMP                                                      ->84
         82    >   QM_ASSIGN                                        ~67     'a'
         83      > JMP                                                      ->86
         84    >   QM_ASSIGN                                        ~67     'b'
         85      > JMP                                                      ->86
         86    >   BIND_STATIC                                              !23, ~67
   42    87        ZEND_BIND_INIT_STATIC_OR_JMP                             !24
         88        NEW                                              $68     'Expressions'
         89        DO_FCALL                                      0          
         90        INIT_METHOD_CALL                                         $68, 'bar'
         91        DO_FCALL                                      0  $70     
         92        BIND_STATIC                                              !24, $70
   43    93        ZEND_BIND_INIT_STATIC_OR_JMP                             !25
         94        NEW                                              $71     'Expressions'
         95        DO_FCALL                                      0          
         96        JMP_NULL                                         $73     $71
         97        INIT_METHOD_CALL                                         $71, 'bar'
         98        DO_FCALL                                      0  $73     
         99        BIND_STATIC                                              !25, $73
   44   100        ZEND_BIND_INIT_STATIC_OR_JMP                             !26
        101        POST_INC                                         ~74     !0
        102        BIND_STATIC                                              !26, ~74
   45   103        ZEND_BIND_INIT_STATIC_OR_JMP                             !27
        104        ECHO                                                     ''
        105        BIND_STATIC                                              !27, 1
   46   106        ZEND_BIND_INIT_STATIC_OR_JMP                             !28
        107        INIT_FCALL                                               'shell_exec'
        108        SEND_VAL                                                 'whoami'
        109        DO_ICALL                                         $75     
        110        BIND_STATIC                                              !28, $75
   47   111        ZEND_BIND_INIT_STATIC_OR_JMP                             !29
        112        INIT_STATIC_METHOD_CALL                                  'baz'
        113        DO_FCALL                                      0  $76     
        114        BIND_STATIC                                              !29, $76
   48   115        ZEND_BIND_INIT_STATIC_OR_JMP                             !30
        116        FETCH_STATIC_PROP_R          unknown             ~77     'b'
        117        BIND_STATIC                                              !30, ~77
   49   118        ZEND_BIND_INIT_STATIC_OR_JMP                             !31
        119        BIND_STATIC                                              !31, !0
   52   120        ZEND_BIND_INIT_STATIC_OR_JMP                             !32
        121        NEW                                              $78     'Expressions'
        122        DO_FCALL                                      0          
        123        JMP_NULL                                         ~80     $78
        124        FETCH_OBJ_R                                      ~80     $78, 'a'
        125        BIND_STATIC                                              !32, ~80
   53   126        ZEND_BIND_INIT_STATIC_OR_JMP                             !33
        127        NEW                                              $81     'Expressions'
        128        DO_FCALL                                      0          
        129        FETCH_OBJ_R                                      ~83     $81, 'a'
        130        BIND_STATIC                                              !33, ~83
   54   131      > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NLM69
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E > > RETURN                                                   1
          1*     > 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/NLM69
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E > > RETURN                                                   1
          1*     > 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/NLM69
function name:  {closure}
number of ops:  2
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   BIND_STATIC                                              !0
          1      > RETURN                                                   null

End of Dynamic Function 2

End of function foo

End of class Expressions.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.03 ms | 1027 KiB | 15 Q