php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40011 Request for refcount function
Submitted: 2007-01-03 13:24 UTC Modified: 2007-01-03 13:27 UTC
From: emiel dot bruijntjes at copernica dot nl Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.2.0 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: emiel dot bruijntjes at copernica dot nl
New email:
PHP Version: OS:

 

 [2007-01-03 13:24 UTC] emiel dot bruijntjes at copernica dot nl
Description:
------------
Currently, I filter out the content of the function debug_zval_dump() to get the reference count of a variable. It would be better if there was a function in PHP to get this information straight away, without the need for parsing output.

Reproduce code:
---------------
// My current code:
ob_start();
debug_zval_dump($var);
$output = ob_get_contents();
ob_end_clean();
$pos = strpos($output, "refcount(");
if ($pos === false) return 0;
$refcount = intval(substr($output, $pos + 9));

// Feature request:
$refcount = refcount($var);

Expected result:
----------------
The internal refcount of a variable

Actual result:
--------------
N/A

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-03 13:27 UTC] derick@php.net
This function is inherently flawed as by passing the variable to the function the refcount (and other bits) might already be changed. Therefore you shouldn't count on this function too much anyway.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 09:01:29 2024 UTC