php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74279 refcount is diffrent from php 5.6.25
Submitted: 2017-03-21 04:16 UTC Modified: 2017-03-21 04:36 UTC
From: gang dot ji at 100dos dot com Assigned:
Status: Duplicate Package: Variables related
PHP Version: 7.1Git-2017-03-21 (Git) OS: mac os 10.11.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
25 + 27 = ?
Subscribe to this entry?

 
 [2017-03-21 04:16 UTC] gang dot ji at 100dos dot com
Description:
------------
tiger➜/opt/work/tmp» cat ref_count.php                                                                                                                                                                 [12:10:32]
<?php
$var1 = 'Hello World';
$var2 = '';

$var2 =& $var1;

debug_zval_dump($var1);
tiger➜/opt/work/tmp» php ref_count.php                                                                                                                                                                 [12:10:35]
string(11) "Hello World" refcount(3)

Test script:
---------------
tiger➜/opt/work/tmp» cat ref_count.php                                                                                                                                                                 [12:10:32]
<?php
$var1 = 'Hello World';
$var2 = '';

$var2 =& $var1;

debug_zval_dump($var1);
tiger➜/opt/work/tmp» php ref_count.php                                                                                                                                                                 [12:10:35]
string(11) "Hello World" refcount(3)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-21 04:36 UTC] requinix@php.net
-Status: Open +Status: Duplicate -Package: Performance problem +Package: Variables related
 [2017-03-21 04:36 UTC] requinix@php.net
debug_zval_dump's refcount was already a bit broken before PHP 7 came along: since call-time pass-by-ref is not available, theoretically the refcount should always be 1 or 2, but that's not terribly helpful. Then PHP 7 started making more changes to how variables move around.

Since 7.1.2 the example shows refcount(3), which is more useful but blatantly contradictory to the docs. https://3v4l.org/ntX3A In PHP 5.6 it shows refcount(1) which is less useful but agrees with the docs.

Two issues here, both covered in other bugs already:
1. Docs are incorrect - bug #72283
2. debug_zval_dump is simply not accurate anymore and something else should replace it - request #67847
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 15:01:29 2024 UTC