php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #701 object references are inconsistent
Submitted: 1998-08-27 21:58 UTC Modified: 1998-08-30 16:19 UTC
From: z-kimmel at uiuc dot edu Assigned:
Status: Closed Package: Parser error
PHP Version: 3.0.3 OS: NT
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: z-kimmel at uiuc dot edu
New email:
PHP Version: OS:

 

 [1998-08-27 21:58 UTC] z-kimmel at uiuc dot edu
Object references appear to change every time a change is made to the object, at least under NT. This means that you can't store mutable objects inside an array, for example. This is bad!

<?php

class example {

var $a;

function test() {
	$temp=$this;
	$this->a=10;
	return $temp;
	}

}

$c = new example;
$c->a=1;
$result=$c->test();
print($result->a);

# prints out the number 1, not the number 10!!

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-08-30 16:19 UTC] zeev
There's no concept of references in PHP, even though there
might be in the future (the word 'might' is intentional).

Your example behaves exactly as expected, once you
understand that two variables never point to the same
data (except for one specific case, which is passing by
reference in function calls).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 17:01:31 2024 UTC