3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_refcount($v) { ob_start(); debug_zval_dump($v); $m = null; preg_match('@refcount\(\d+\)@', ob_get_clean(), $m); return $m[0]; } function func(&$data) { foreach ($data as $key => $value) { if (is_array($value)) { func($data[$key]); } } } $data = [ ['k' => [0]], ['k' => [1]], ]; echo get_refcount($data[1]['k'])."\n"; //refcount(2) func($data); echo get_refcount($data[1]['k'])."\n"; //refcount(3) array_replace_recursive($data[0], $data[1]); echo json_encode($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3dLqC
function name:  (null)
number of ops:  29
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, <array>
   24     1        INIT_FCALL                                               'get_refcount'
          2        FETCH_DIM_R                                      ~2      !0, 1
          3        FETCH_DIM_R                                      ~3      ~2, 'k'
          4        SEND_VAL                                                 ~3
          5        DO_FCALL                                      0  $4      
          6        CONCAT                                           ~5      $4, '%0A'
          7        ECHO                                                     ~5
   25     8        INIT_FCALL                                               'func'
          9        SEND_REF                                                 !0
         10        DO_FCALL                                      0          
   26    11        INIT_FCALL                                               'get_refcount'
         12        FETCH_DIM_R                                      ~7      !0, 1
         13        FETCH_DIM_R                                      ~8      ~7, 'k'
         14        SEND_VAL                                                 ~8
         15        DO_FCALL                                      0  $9      
         16        CONCAT                                           ~10     $9, '%0A'
         17        ECHO                                                     ~10
   27    18        INIT_FCALL                                               'array_replace_recursive'
         19        FETCH_DIM_R                                      ~11     !0, 0
         20        SEND_VAL                                                 ~11
         21        FETCH_DIM_R                                      ~12     !0, 1
         22        SEND_VAL                                                 ~12
         23        DO_ICALL                                                 
   28    24        INIT_FCALL                                               'json_encode'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $14     
         27        ECHO                                                     $14
         28      > RETURN                                                   1

Function get_refcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3dLqC
function name:  get_refcount
number of ops:  17
compiled vars:  !0 = $v, !1 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'ob_start'
          2        DO_ICALL                                                 
    5     3        INIT_FCALL                                               'debug_zval_dump'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
    6     6        ASSIGN                                                   !1, null
    7     7        INIT_FCALL                                               'preg_match'
          8        SEND_VAL                                                 '%40refcount%5C%28%5Cd%2B%5C%29%40'
          9        INIT_FCALL                                               'ob_get_clean'
         10        DO_ICALL                                         $5      
         11        SEND_VAR                                                 $5
         12        SEND_REF                                                 !1
         13        DO_ICALL                                                 
    8    14        FETCH_DIM_R                                      ~7      !1, 0
         15      > RETURN                                                   ~7
    9    16*     > RETURN                                                   null

End of function get_refcount

Function func:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/3dLqC
function name:  func
number of ops:  14
compiled vars:  !0 = $data, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->12
          3    >   ASSIGN                                                   !2, ~4
   13     4        TYPE_CHECK                                  128          !1
          5      > JMPZ                                                     ~6, ->11
   14     6    >   INIT_FCALL_BY_NAME                                       'func'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_DIM_FUNC_ARG                               $7      !0, !2
          9        SEND_FUNC_ARG                                            $7
         10        DO_FCALL                                      0          
   12    11    > > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   17    13      > RETURN                                                   null

End of function func

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.44 ms | 1403 KiB | 28 Q