php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73516 Static variable and pointer problem
Submitted: 2016-11-14 13:42 UTC Modified: 2020-01-08 13:41 UTC
From: info at project dot mn Assigned: nikic (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.6.28 OS: Any OS
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: info at project dot mn
New email:
PHP Version: OS:

 

 [2016-11-14 13:42 UTC] info at project dot mn
Description:
------------
Object oriented concept not work when i use pointer(&) on static variable.Static variable of Parent and child class has diffrent value at same time


Test script:
---------------
class a1{
    public static $obj='';
}
class b1 extends a1{
    
}


class c{
    public $forprint='cccObject';
}
class d{
    public $forprint='dddObject';
}

$c=new c();
$d=new d();
b1::$obj=& $d;
a1::$obj=& $c;
echo b1::$obj->forprint;
//out put must be print cccObject but it print dddObject in php

Actual result:
--------------
dddObject

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-08 13:41 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2020-01-08 13:41 UTC] nikic@php.net
This has been fixed in PHP 7.3, where we removed the internal use of references for static class members.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 13:01:29 2024 UTC