3v4l.org

run code in 300+ PHP versions simultaneously
<?php function remove_recursion($o){ static $replace; if(!isset($replace)) $replace = create_function('$m','$r="\x00{$m[1]}ecursion_";return \'s:\'.strlen($r.$m[2]).\':"\'.$r.$m[2].\'";\';') ; if(is_array($o) || is_object($o)){ $re = '#(r|R):([0-9]+);#'; $serialize = serialize($o); if(preg_match($re, $serialize)){ $last = $pos = 0; while(false !== ($pos = strpos($serialize, 's:', $pos))){ $chunk = substr($serialize, $last, $pos - $last); if(preg_match($re, $chunk)){ $length = strlen($chunk); $chunk = preg_replace_callback($re, $replace, $chunk); $serialize = substr($serialize, 0, $last).$chunk.substr($serialize, $last + ($pos - $last)); $pos += strlen($chunk) - $length; } $pos += 2; $last = strpos($serialize, ':', $pos); $length = substr($serialize, $pos, $last- $pos); $last += 4 + $length; $pos = $last; } $serialize = substr($serialize, 0, $last).preg_replace_callback($re, $replace, substr($serialize, $last)); $o = unserialize($serialize); } } return $o; } $o = new stdClass; $o->n = function($a) { return $a; }; $o->r = &$o; echo serialize($o), ' ', serialize( remove_recursion($o) ) ;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lOjLg
function name:  (null)
number of ops:  21
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $1      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   34     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FlOjLg%3A34%240'
          4        ASSIGN_OBJ                                               !0, 'n'
          5        OP_DATA                                                  ~5
   35     6        ASSIGN_OBJ_REF                                           !0, 'r'
          7        OP_DATA                                                  !0
   37     8        INIT_FCALL                                               'serialize'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $7      
         11        ECHO                                                     $7
         12        ECHO                                                     '%0A'
   39    13        INIT_FCALL                                               'serialize'
   40    14        INIT_FCALL                                               'remove_recursion'
         15        SEND_VAR                                                 !0
         16        DO_FCALL                                      0  $8      
         17        SEND_VAR                                                 $8
         18        DO_ICALL                                         $9      
         19        ECHO                                                     $9
   42    20      > RETURN                                                   1

Function remove_recursion:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 47) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 110
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 110
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 82
Branch analysis from position: 82
2 jumps found. (Code = 44) Position 1 = 90, Position 2 = 28
Branch analysis from position: 90
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 65
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 90, Position 2 = 28
Branch analysis from position: 90
Branch analysis from position: 28
Branch analysis from position: 65
Branch analysis from position: 110
Branch analysis from position: 110
Branch analysis from position: 14
Branch analysis from position: 10
filename:       /in/lOjLg
function name:  remove_recursion
number of ops:  112
compiled vars:  !0 = $o, !1 = $replace, !2 = $re, !3 = $serialize, !4 = $last, !5 = $pos, !6 = $chunk, !7 = $length
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        BIND_STATIC                                              !1
    4     2        ISSET_ISEMPTY_CV                                 ~8      !1
          3        BOOL_NOT                                         ~9      ~8
          4      > JMPZ                                                     ~9, ->10
    5     5    >   INIT_FCALL_BY_NAME                                       'create_function'
          6        SEND_VAL_EX                                              '%24m'
          7        SEND_VAL_EX                                              '%24r%3D%22%5Cx00%7B%24m%5B1%5D%7Decursion_%22%3Breturn+%27s%3A%27.strlen%28%24r.%24m%5B2%5D%29.%27%3A%22%27.%24r.%24m%5B2%5D.%27%22%3B%27%3B'
          8        DO_FCALL                                      0  $10     
          9        ASSIGN                                                   !1, $10
    7    10    >   TYPE_CHECK                                  128  ~12     !0
         11      > JMPNZ_EX                                         ~12     ~12, ->14
         12    >   TYPE_CHECK                                  256  ~13     !0
         13        BOOL                                             ~12     ~13
         14    > > JMPZ                                                     ~12, ->110
    8    15    >   ASSIGN                                                   !2, '%23%28r%7CR%29%3A%28%5B0-9%5D%2B%29%3B%23'
    9    16        INIT_FCALL                                               'serialize'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $15     
         19        ASSIGN                                                   !3, $15
   10    20        INIT_FCALL                                               'preg_match'
         21        SEND_VAR                                                 !2
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                         $17     
         24      > JMPZ                                                     $17, ->110
   11    25    >   ASSIGN                                           ~18     !5, 0
         26        ASSIGN                                                   !4, ~18
   12    27      > JMP                                                      ->82
   13    28    >   INIT_FCALL                                               'substr'
         29        SEND_VAR                                                 !3
         30        SEND_VAR                                                 !4
         31        SUB                                              ~20     !5, !4
         32        SEND_VAL                                                 ~20
         33        DO_ICALL                                         $21     
         34        ASSIGN                                                   !6, $21
   14    35        INIT_FCALL                                               'preg_match'
         36        SEND_VAR                                                 !2
         37        SEND_VAR                                                 !6
         38        DO_ICALL                                         $23     
         39      > JMPZ                                                     $23, ->65
   15    40    >   STRLEN                                           ~24     !6
         41        ASSIGN                                                   !7, ~24
   16    42        INIT_FCALL                                               'preg_replace_callback'
         43        SEND_VAR                                                 !2
         44        SEND_VAR                                                 !1
         45        SEND_VAR                                                 !6
         46        DO_ICALL                                         $26     
         47        ASSIGN                                                   !6, $26
   17    48        INIT_FCALL                                               'substr'
         49        SEND_VAR                                                 !3
         50        SEND_VAL                                                 0
         51        SEND_VAR                                                 !4
         52        DO_ICALL                                         $28     
         53        CONCAT                                           ~29     $28, !6
         54        INIT_FCALL                                               'substr'
         55        SEND_VAR                                                 !3
         56        SUB                                              ~30     !5, !4
         57        ADD                                              ~31     !4, ~30
         58        SEND_VAL                                                 ~31
         59        DO_ICALL                                         $32     
         60        CONCAT                                           ~33     ~29, $32
         61        ASSIGN                                                   !3, ~33
   18    62        STRLEN                                           ~35     !6
         63        SUB                                              ~36     ~35, !7
         64        ASSIGN_OP                                     1          !5, ~36
   20    65    >   ASSIGN_OP                                     1          !5, 2
   21    66        INIT_FCALL                                               'strpos'
         67        SEND_VAR                                                 !3
         68        SEND_VAL                                                 '%3A'
         69        SEND_VAR                                                 !5
         70        DO_ICALL                                         $39     
         71        ASSIGN                                                   !4, $39
   22    72        INIT_FCALL                                               'substr'
         73        SEND_VAR                                                 !3
         74        SEND_VAR                                                 !5
         75        SUB                                              ~41     !4, !5
         76        SEND_VAL                                                 ~41
         77        DO_ICALL                                         $42     
         78        ASSIGN                                                   !7, $42
   23    79        ADD                                              ~44     4, !7
         80        ASSIGN_OP                                     1          !4, ~44
   24    81        ASSIGN                                                   !5, !4
   12    82    >   INIT_FCALL                                               'strpos'
         83        SEND_VAR                                                 !3
         84        SEND_VAL                                                 's%3A'
         85        SEND_VAR                                                 !5
         86        DO_ICALL                                         $47     
         87        ASSIGN                                           ~48     !5, $47
         88        TYPE_CHECK                                  1018          ~48
         89      > JMPNZ                                                    ~49, ->28
   26    90    >   INIT_FCALL                                               'substr'
         91        SEND_VAR                                                 !3
         92        SEND_VAL                                                 0
         93        SEND_VAR                                                 !4
         94        DO_ICALL                                         $50     
         95        INIT_FCALL                                               'preg_replace_callback'
         96        SEND_VAR                                                 !2
         97        SEND_VAR                                                 !1
         98        INIT_FCALL                                               'substr'
         99        SEND_VAR                                                 !3
        100        SEND_VAR                                                 !4
        101        DO_ICALL                                         $51     
        102        SEND_VAR                                                 $51
        103        DO_ICALL                                         $52     
        104        CONCAT                                           ~53     $50, $52
        105        ASSIGN                                                   !3, ~53
   27   106        INIT_FCALL                                               'unserialize'
        107        SEND_VAR                                                 !3
        108        DO_ICALL                                         $55     
        109        ASSIGN                                                   !0, $55
   30   110    > > RETURN                                                   !0
   31   111*     > RETURN                                                   null

End of function remove_recursion

Function %00%7Bclosure%7D%2Fin%2FlOjLg%3A34%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lOjLg
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1      > RETURN                                                   !0
          2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FlOjLg%3A34%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.01 ms | 1410 KiB | 26 Q