php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24546 Object ID number does not increase
Submitted: 2003-07-08 15:14 UTC Modified: 2003-07-08 15:26 UTC
From: proton at fangen dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2003-07-08 (dev) OS: Irrelevant
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: proton at fangen dot net
New email:
PHP Version: OS:

 

 [2003-07-08 15:14 UTC] proton at fangen dot net
Description:
------------
When creating an object, each created object should have a unique (zend engine 2 internal) Object ID, right? The code below always prints "Object id #1", i.e. the objects have the same ID. Although they are instances of an empty (no methods or properties) class, I had the same problem with classes that did have methods and/or properties. 

Here's a short script that reproduces the problem:

Reproduce code:
---------------
class MyClass
{

}

function test()
{
	$c = new MyClass();
	print $c; // Will always print "Object id #1"
}

test();
test();

Expected result:
----------------
Object id #1
Object id #2

Actual result:
--------------
Object id #1
Object id #1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-08 15:24 UTC] derick@php.net
I could reproduce this under linux (with beta1).

Derick
 [2003-07-08 15:26 UTC] derick@php.net
This is not a bug, run this code and you'll see why:

<?php
class MyClass
{
    function __destruct() {
        echo "dtor\n";
    }
}

function test()
{
        $c = new MyClass();
        print $c."\n"; // Will always print "Object id #1"
}

test();
test();
?>

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 30 16:00:03 2025 UTC