3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = 1; $b = 2; $x = [1, 2]; file_put_contents('/tmp/a.php', ''); class Foo { public $a = 1; public static $b = 3; function bar() {} static function baz() {} } static $array = [1, 2, 3]; static $arrayDimFetch = [1,2][0]; static $arrayItem = ['a' => 1]; static $binaryBitwiseAnd = 1 & 2; static $binaryConcat = "a" . "b"; static $binaryIdentical = 1 === 1; static $binaryPlus = 1 + 2; static $binarySpaceship = 1 <=> 2; static $bitwiseNot = ~1; static $booleanAnd = 1 && 2; static $booleanNot = !false; static $classConstFetch = Foo::class; static $coalesce = 1 ?? 2; static $constFetch = PHP_EOL; static $new = new stdClass(); static $scalarFloat = 3.14; static $scalarInteger = 123; static $scalarMagicConst = __LINE__; static $scalarString = 'string'; static $ternary = true ? 1 : 2; static $unaryPlus = +1; // Was invalid inside a function but valid outside static $propertyFetch = (new Foo())->a; // works when not in a function static $nullsafePropertyFetch = (new Foo())?->a; // works when not in a function // Fatal errors in PHP 8.2 for each statement below static $arrowFunction = fn() => 1; static $assign = ($a = 1); static $assignOpAnd = ($a &= 1); static $assignOpConcat = ($a .= "b"); static $assignOpDiv = ($b /= 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 Foo; static $isset = isset($x); static $list = [[$a, $b] = [1, 2]]; static $match = match (1) {1 => 'a', default => 'b'}; static $methodCall = (new Foo())->bar(); static $nullsafeMethodCall = (new Foo())?->bar(); static $postInc = $a++; static $print = print ''; static $shellExec = `whoami`; // expected warning due to sandbox environment static $staticCall = Foo::baz(); static $staticPropertyFetch = Foo::$b; static $variable = $a;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 113, Position 2 = 114
Branch analysis from position: 113
1 jumps found. (Code = 42) Position 1 = 116
Branch analysis from position: 116
1 jumps found. (Code = 42) Position 1 = 118
Branch analysis from position: 118
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 114
1 jumps found. (Code = 42) Position 1 = 118
Branch analysis from position: 118
filename:       /in/n2q2Z
function name:  (null)
number of ops:  153
compiled vars:  !0 = $a, !1 = $b, !2 = $x, !3 = $array, !4 = $arrayDimFetch, !5 = $arrayItem, !6 = $binaryBitwiseAnd, !7 = $binaryConcat, !8 = $binaryIdentical, !9 = $binaryPlus, !10 = $binarySpaceship, !11 = $bitwiseNot, !12 = $booleanAnd, !13 = $booleanNot, !14 = $classConstFetch, !15 = $coalesce, !16 = $constFetch, !17 = $new, !18 = $scalarFloat, !19 = $scalarInteger, !20 = $scalarMagicConst, !21 = $scalarString, !22 = $ternary, !23 = $unaryPlus, !24 = $propertyFetch, !25 = $nullsafePropertyFetch, !26 = $arrowFunction, !27 = $assign, !28 = $assignOpAnd, !29 = $assignOpConcat, !30 = $assignOpDiv, !31 = $assignRef, !32 = $castInt, !33 = $clone, !34 = $closure, !35 = $closureUse, !36 = $empty, !37 = $encapsed, !38 = $errorSuppress, !39 = $eval, !40 = $funcCall, !41 = $include, !42 = $instanceof, !43 = $isset, !44 = $list, !45 = $match, !46 = $methodCall, !47 = $nullsafeMethodCall, !48 = $postInc, !49 = $print, !50 = $shellExec, !51 = $staticCall, !52 = $staticPropertyFetch, !53 = $variable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 1
    4     1        ASSIGN                                                   !1, 2
    5     2        ASSIGN                                                   !2, <array>
    6     3        INIT_FCALL                                               'file_put_contents'
          4        SEND_VAL                                                 '%2Ftmp%2Fa.php'
          5        SEND_VAL                                                 ''
          6        DO_ICALL                                                 
   15     7        BIND_STATIC                                              !3
   16     8        BIND_STATIC                                              !4
   17     9        BIND_STATIC                                              !5
   18    10        BIND_STATIC                                              !6
   19    11        BIND_STATIC                                              !7
   20    12        BIND_STATIC                                              !8
   21    13        BIND_STATIC                                              !9
   22    14        BIND_STATIC                                              !10
   23    15        BIND_STATIC                                              !11
   24    16        BIND_STATIC                                              !12
   25    17        BIND_STATIC                                              !13
   26    18        BIND_STATIC                                              !14
   27    19        BIND_STATIC                                              !15
   28    20        BIND_STATIC                                              !16
   29    21        ZEND_BIND_INIT_STATIC_OR_JMP                             !17
         22        NEW                                              $58     'stdClass'
         23        DO_FCALL                                      0          
         24        BIND_STATIC                                              !17, $58
   30    25        BIND_STATIC                                              !18
   31    26        BIND_STATIC                                              !19
   32    27        BIND_STATIC                                              !20
   33    28        BIND_STATIC                                              !21
   34    29        BIND_STATIC                                              !22
   35    30        BIND_STATIC                                              !23
   38    31        ZEND_BIND_INIT_STATIC_OR_JMP                             !24
         32        NEW                                              $60     'Foo'
         33        DO_FCALL                                      0          
         34        FETCH_OBJ_R                                      ~62     $60, 'a'
         35        BIND_STATIC                                              !24, ~62
   39    36        ZEND_BIND_INIT_STATIC_OR_JMP                             !25
         37        NEW                                              $63     'Foo'
         38        DO_FCALL                                      0          
         39        JMP_NULL                                         ~65     $63
         40        FETCH_OBJ_R                                      ~65     $63, 'a'
         41        BIND_STATIC                                              !25, ~65
   42    42        ZEND_BIND_INIT_STATIC_OR_JMP                             !26
         43        DECLARE_LAMBDA_FUNCTION                          ~66     [0]
         44        BIND_STATIC                                              !26, ~66
   43    45        ZEND_BIND_INIT_STATIC_OR_JMP                             !27
         46        ASSIGN                                           ~67     !0, 1
         47        BIND_STATIC                                              !27, ~67
   44    48        ZEND_BIND_INIT_STATIC_OR_JMP                             !28
         49        ASSIGN_OP                                    10  ~68     !0, 1
         50        BIND_STATIC                                              !28, ~68
   45    51        ZEND_BIND_INIT_STATIC_OR_JMP                             !29
         52        ASSIGN_OP                                     8  ~69     !0, 'b'
         53        BIND_STATIC                                              !29, ~69
   46    54        ZEND_BIND_INIT_STATIC_OR_JMP                             !30
         55        ASSIGN_OP                                     4  ~70     !1, 2
         56        BIND_STATIC                                              !30, ~70
   47    57        ZEND_BIND_INIT_STATIC_OR_JMP                             !31
         58        ASSIGN_REF                                       $71     !0, !1
         59        BIND_STATIC                                              !31, $71
   48    60        ZEND_BIND_INIT_STATIC_OR_JMP                             !32
         61        CAST                                          4  ~72     '1'
         62        BIND_STATIC                                              !32, ~72
   49    63        ZEND_BIND_INIT_STATIC_OR_JMP                             !33
         64        NEW                                              $73     'stdClass'
         65        DO_FCALL                                      0          
         66        CLONE                                            ~75     $73
         67        BIND_STATIC                                              !33, ~75
   50    68        ZEND_BIND_INIT_STATIC_OR_JMP                             !34
         69        DECLARE_LAMBDA_FUNCTION                          ~76     [1]
         70        BIND_STATIC                                              !34, ~76
   51    71        ZEND_BIND_INIT_STATIC_OR_JMP                             !35
         72        DECLARE_LAMBDA_FUNCTION                          ~77     [2]
         73        BIND_LEXICAL                                             ~77, !2
         74        BIND_STATIC                                              !35, ~77
   52    75        ZEND_BIND_INIT_STATIC_OR_JMP                             !36
         76        BIND_STATIC                                              !36, <false>
   53    77        ZEND_BIND_INIT_STATIC_OR_JMP                             !37
         78        NOP                                                      
         79        FAST_CONCAT                                      ~78     'Value%3A+', !0
         80        BIND_STATIC                                              !37, ~78
   54    81        ZEND_BIND_INIT_STATIC_OR_JMP                             !38
         82        BEGIN_SILENCE                                    ~79     
         83        NEW                                              $80     'stdClass'
         84        DO_FCALL                                      0          
         85        END_SILENCE                                              ~79
         86        BIND_STATIC                                              !38, $80
   55    87        ZEND_BIND_INIT_STATIC_OR_JMP                             !39
         88        INCLUDE_OR_EVAL                                  $82     '1%2B1%3B', EVAL
         89        BIND_STATIC                                              !39, $82
   56    90        ZEND_BIND_INIT_STATIC_OR_JMP                             !40
         91        BIND_STATIC                                              !40, 1
   57    92        ZEND_BIND_INIT_STATIC_OR_JMP                             !41
         93        INCLUDE_OR_EVAL                                  $83     '%2Ftmp%2Fa.php', INCLUDE
         94        BIND_STATIC                                              !41, $83
   58    95        ZEND_BIND_INIT_STATIC_OR_JMP                             !42
         96        NEW                                              $84     'stdClass'
         97        DO_FCALL                                      0          
         98        INSTANCEOF                                       ~86     $84, 'Foo'
         99        BIND_STATIC                                              !42, ~86
   59   100        ZEND_BIND_INIT_STATIC_OR_JMP                             !43
        101        ISSET_ISEMPTY_CV                                 ~87     !2
        102        BIND_STATIC                                              !43, ~87
   60   103        ZEND_BIND_INIT_STATIC_OR_JMP                             !44
        104        FETCH_LIST_R                                     $88     <array>, 0
        105        ASSIGN                                                   !0, $88
        106        FETCH_LIST_R                                     $90     <array>, 1
        107        ASSIGN                                                   !1, $90
        108        INIT_ARRAY                                       ~92     <array>
        109        BIND_STATIC                                              !44, ~92
   61   110        ZEND_BIND_INIT_STATIC_OR_JMP                             !45
        111        IS_IDENTICAL                                             1, 1
        112      > JMPNZ                                                    ~93, ->114
        113    > > JMP                                                      ->116
        114    >   QM_ASSIGN                                        ~94     'a'
        115      > JMP                                                      ->118
        116    >   QM_ASSIGN                                        ~94     'b'
        117      > JMP                                                      ->118
        118    >   BIND_STATIC                                              !45, ~94
   62   119        ZEND_BIND_INIT_STATIC_OR_JMP                             !46
        120        NEW                                              $95     'Foo'
        121        DO_FCALL                                      0          
        122        INIT_METHOD_CALL                                         $95, 'bar'
        123        DO_FCALL                                      0  $97     
        124        BIND_STATIC                                              !46, $97
   63   125        ZEND_BIND_INIT_STATIC_OR_JMP                             !47
        126        NEW                                              $98     'Foo'
        127        DO_FCALL                                      0          
        128        JMP_NULL                                         $100    $98
        129        INIT_METHOD_CALL                                         $98, 'bar'
        130        DO_FCALL                                      0  $100    
        131        BIND_STATIC                                              !47, $100
   64   132        ZEND_BIND_INIT_STATIC_OR_JMP                             !48
        133        POST_INC                                         ~101    !0
        134        BIND_STATIC                                              !48, ~101
   65   135        ZEND_BIND_INIT_STATIC_OR_JMP                             !49
        136        ECHO                                                     ''
        137        BIND_STATIC                                              !49, 1
   66   138        ZEND_BIND_INIT_STATIC_OR_JMP                             !50
        139        INIT_FCALL                                               'shell_exec'
        140        SEND_VAL                                                 'whoami'
        141        DO_ICALL                                         $102    
        142        BIND_STATIC                                              !50, $102
   67   143        ZEND_BIND_INIT_STATIC_OR_JMP                             !51
        144        INIT_STATIC_METHOD_CALL                                  'Foo', 'baz'
        145        DO_FCALL                                      0  $103    
        146        BIND_STATIC                                              !51, $103
   68   147        ZEND_BIND_INIT_STATIC_OR_JMP                             !52
        148        FETCH_STATIC_PROP_R          unknown             ~104    'b'
        149        BIND_STATIC                                              !52, ~104
   69   150        ZEND_BIND_INIT_STATIC_OR_JMP                             !53
        151        BIND_STATIC                                              !53, !0
   70   152      > 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/n2q2Z
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     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/n2q2Z
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     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/n2q2Z
function name:  {closure}
number of ops:  2
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   BIND_STATIC                                              !0
          1      > RETURN                                                   null

End of Dynamic Function 2

Class Foo:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n2q2Z
function name:  bar
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     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/n2q2Z
function name:  baz
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E > > RETURN                                                   null

End of function baz

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
252.95 ms | 1031 KiB | 16 Q