|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-03-10 16:27 UTC] tangi dot maury at wanadoo dot fr
Description:
------------
I'd like use '=null' on variables who points to object.
but the refcount is not updated in this case.
It is updated only after unset on variable.
is it a real pb ?
By,
Reproduce code:
---------------
a small test ->
class a{
}
class b extends a{
}
class t{
var $r = null;
var $pr = null;
function test(){
$this->r = &new b();
echo "nb Ref r apres new = " . pars_infoo($this->r);
$this->pr = &$this->r;
echo "<br/>nb Ref pr apres pr = " . pars_infoo($this->r);
echo "<br/>nb Ref r apres pr = " . pars_infoo($this->pr);
//unset($this->pr); OK
$this->pr = null;
echo "<br/> nb Ref r apres unset " . pars_infoo($this->r);
}
}
$b= new t();
$b->test();
source for pars_infoo(Zend)
if ((*pO)->is_ref)
ret = strUWFormat(ret, nPos, &nPos, "nb r?f?rence = %hd", (*pO)->refcount);
Expected result:
----------------
if i make unset it's ok
->
nb Ref r apres unset nb r?f?rence = 2 <- ok
Actual result:
--------------
->
nb Ref r apres new = nb r?f?rence = 2
nb Ref pr apres pr = nb r?f?rence = 3
nb Ref r apres pr = nb r?f?rence = 3
nb Ref r apres unset nb r?f?rence = 3 <- wrong
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 04:00:01 2025 UTC |
I write it in Zend Language and compile with vc++ 6. static const unsigned char arg_ref[] = {1, BYREF_FORCE}; PHP_FE(pars_infoo, (unsigned char *) arg_ref) PHP_FUNCTION(pars_infoo){ pval ** pO = NULL; char ret[50]; ret[0] = 0; if (zend_get_parameters_ex(1, &pO) == FAILURE) return; if ((*pO)->is_ref) sprintf(ret, "ref count = %hd", (*pO)->refcount); RETVAL_STRING(ret, 1); return; }Whith debug_zval_dump i have the result 1 -> object(b)(0) refcount(1){ } It's alays the same refcount, even i refer the object more than once. I think it's a wrong test.