3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (defined('HHVM_VERSION')) { exit; } function refcount($var) { ob_start(); debug_zval_dump($var); $dump = ob_get_clean(); $matches = array(); preg_match('/refcount\(([0-9]+)/', $dump, $matches); $count = $matches[1]; //3 references are added, including when calling debug_zval_dump() return $count - 3; } $array = array('foo' => 'bar'); var_dump(refcount($array)); $copy = $array; var_dump(refcount($array)); var_dump(refcount($copy)); current($copy); var_dump(refcount($array)); var_dump(refcount($copy));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 3
Branch analysis from position: 2
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2eCbt
function name:  (null)
number of ops:  39
compiled vars:  !0 = $array, !1 = $copy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DEFINED                                                  'HHVM_VERSION'
          1      > JMPZ                                                     ~2, ->3
    4     2    > > EXIT                                                     
   22     3    >   ASSIGN                                                   !0, <array>
   23     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'refcount'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
   24    10        ASSIGN                                                   !1, !0
   25    11        INIT_FCALL                                               'var_dump'
         12        INIT_FCALL                                               'refcount'
         13        SEND_VAR                                                 !0
         14        DO_FCALL                                      0  $7      
         15        SEND_VAR                                                 $7
         16        DO_ICALL                                                 
   26    17        INIT_FCALL                                               'var_dump'
         18        INIT_FCALL                                               'refcount'
         19        SEND_VAR                                                 !1
         20        DO_FCALL                                      0  $9      
         21        SEND_VAR                                                 $9
         22        DO_ICALL                                                 
   27    23        INIT_FCALL                                               'current'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                                 
   28    26        INIT_FCALL                                               'var_dump'
         27        INIT_FCALL                                               'refcount'
         28        SEND_VAR                                                 !0
         29        DO_FCALL                                      0  $12     
         30        SEND_VAR                                                 $12
         31        DO_ICALL                                                 
   29    32        INIT_FCALL                                               'var_dump'
         33        INIT_FCALL                                               'refcount'
         34        SEND_VAR                                                 !1
         35        DO_FCALL                                      0  $14     
         36        SEND_VAR                                                 $14
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

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

End of function refcount

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.2 ms | 1403 KiB | 30 Q