3v4l.org

run code in 500+ PHP versions simultaneously
<?php $i = 0; function is_cyclic(array &$array) { global $i; // Exit when too deep. if (++$i > 10) exit; echo "Call $i:\n"; var_dump($GLOBALS['bomb']); echo "\n"; $lastKey = array_key_last($array); if ($lastKey === null) { // Array is empty return false; } static $marker; if ($marker === null) $marker = new stdClass(); if ($array[$lastKey] === $marker) { return true; } $array[] = $marker; foreach ($array as &$item) { if (is_array($item) && is_cyclic($item)) { //array_pop($array); return true; } } //array_pop($array); return false; } function craft_bomb() { $array = [1, [2, 3]]; $array[1][1] = &$array; return $array; } $bomb = craft_bomb(); is_cyclic($bomb);

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C1d90
function name:  (null)
number of ops:  8
compiled vars:  !0 = $i, !1 = $bomb
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 0
   44     1        INIT_FCALL                                                   'craft_bomb'
          2        DO_FCALL                                          0  $3      
          3        ASSIGN                                                       !1, $3
   45     4        INIT_FCALL                                                   'is_cyclic'
          5        SEND_REF                                                     !1
          6        DO_FCALL                                          0          
          7      > RETURN                                                       1

Function is_cyclic:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 125) Position 1 = 36, Position 2 = 47
Branch analysis from position: 36
2 jumps found. (Code = 126) Position 1 = 37, Position 2 = 47
Branch analysis from position: 37
2 jumps found. (Code = 46) Position 1 = 39, Position 2 = 43
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 43
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Branch analysis from position: 29
filename:       /in/C1d90
function name:  is_cyclic
number of ops:  50
compiled vars:  !0 = $array, !1 = $i, !2 = $lastKey, !3 = $marker, !4 = $item
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
    7     1        BIND_GLOBAL                                                  !1, 'i'
   10     2        PRE_INC                                              ~5      !1
          3        IS_SMALLER                                                   10, ~5
          4      > JMPZ                                                         ~6, ->7
          5    > > INIT_FCALL                                                   'exit'
          6*       DO_ICALL                                                     
   12     7    >   ROPE_INIT                                         3  ~9      'Call+'
          8        ROPE_ADD                                          1  ~9      ~9, !1
          9        ROPE_END                                          2  ~8      ~9, '%3A%0A'
         10        ECHO                                                         ~8
   13    11        INIT_FCALL                                                   'var_dump'
         12        FETCH_R                          global              ~11     'bomb'
         13        SEND_VAL                                                     ~11
         14        DO_ICALL                                                     
   14    15        ECHO                                                         '%0A'
   16    16        INIT_FCALL                                                   'array_key_last'
         17        SEND_VAR                                                     !0
         18        DO_ICALL                                             $13     
         19        ASSIGN                                                       !2, $13
   17    20        TYPE_CHECK                                        2          !2
         21      > JMPZ                                                         ~15, ->23
   19    22    > > RETURN                                                       <false>
   21    23    >   BIND_STATIC                                                  !3
   22    24        TYPE_CHECK                                        2          !3
         25      > JMPZ                                                         ~16, ->29
   23    26    >   NEW                                                  $17     'stdClass'
         27        DO_FCALL                                          0          
         28        ASSIGN                                                       !3, $17
   24    29    >   FETCH_DIM_R                                          ~20     !0, !2
         30        IS_IDENTICAL                                                 !3, ~20
         31      > JMPZ                                                         ~21, ->33
   25    32    > > RETURN                                                       <true>
   27    33    >   ASSIGN_DIM                                                   !0
         34        OP_DATA                                                      !3
   28    35      > FE_RESET_RW                                          $23     !0, ->47
         36    > > FE_FETCH_RW                                                  $23, !4, ->47
   29    37    >   TYPE_CHECK                                      128  ~24     !4
         38      > JMPZ_EX                                              ~24     ~24, ->43
         39    >   INIT_FCALL_BY_NAME                                           'is_cyclic'
         40        SEND_VAR_EX                                                  !4
         41        DO_FCALL                                          0  $25     
         42        BOOL                                                 ~24     $25
         43    > > JMPZ                                                         ~24, ->46
   31    44    >   FE_FREE                                                      $23
         45      > RETURN                                                       <true>
   28    46    > > JMP                                                          ->36
         47    >   FE_FREE                                                      $23
   35    48      > RETURN                                                       <false>
   36    49*     > RETURN                                                       null

End of function is_cyclic

Function craft_bomb:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C1d90
function name:  craft_bomb
number of ops:  6
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   39     0  E >   ASSIGN                                                       !0, <array>
   40     1        FETCH_DIM_W                                          $2      !0, 1
          2        FETCH_DIM_W                                          $3      $2, 1
          3        ASSIGN_REF                                                   $3, !0
   41     4      > RETURN                                                       !0
   42     5*     > RETURN                                                       null

End of function craft_bomb

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178.62 ms | 3032 KiB | 18 Q