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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gang dot ji at 100dos dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sun Dec 22 11:01:30 2024 UTC