3v4l.org

run code in 300+ PHP versions simultaneously
<?php function countRefs($var) { ob_start(); debug_zval_dump($var); preg_match('~refcount\((\d+)\)~', ob_get_clean(), $matches); return $matches[1] - 4; } $a = 0; $a = &$a; echo countRefs($a); $a = &$a; echo countRefs($a);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tTXJf
function name:  (null)
number of ops:  12
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, 0
   11     1        ASSIGN_REF                                               !0, !0
   12     2        INIT_FCALL                                               'countrefs'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $3      
          5        ECHO                                                     $3
   13     6        ASSIGN_REF                                               !0, !0
   14     7        INIT_FCALL                                               'countrefs'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0  $5      
         10        ECHO                                                     $5
         11      > RETURN                                                   1

Function countrefs:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tTXJf
function name:  countRefs
number of ops:  17
compiled vars:  !0 = $var, !1 = $matches
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        INIT_FCALL                                               'preg_match'
          7        SEND_VAL                                                 '%7Erefcount%5C%28%28%5Cd%2B%29%5C%29%7E'
          8        INIT_FCALL                                               'ob_get_clean'
          9        DO_ICALL                                         $4      
         10        SEND_VAR                                                 $4
         11        SEND_REF                                                 !1
         12        DO_ICALL                                                 
    7    13        FETCH_DIM_R                                      ~6      !1, 1
         14        SUB                                              ~7      ~6, 4
         15      > RETURN                                                   ~7
    8    16*     > RETURN                                                   null

End of function countrefs

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.72 ms | 1399 KiB | 23 Q