php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32915 objects of the same class can access private variables
Submitted: 2005-05-02 20:20 UTC Modified: 2005-05-02 21:12 UTC
From: rashid at ds dot pg dot gda dot pl Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.* OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rashid at ds dot pg dot gda dot pl
New email:
PHP Version: OS:

 

 [2005-05-02 20:20 UTC] rashid at ds dot pg dot gda dot pl
Description:
------------
It seems like objects of the same class can access private variables in each other. Access rights check is based on class name instead of reference?

Reproduce code:
---------------
<?php
class strange {
  private $_amount = 10;  
  
  public function foo($other) {
    echo $other->_amount;
    $other->_amount = 666;
  }
}

$t = new strange();
$t->foo(new strange());
?>

Expected result:
----------------
fatal error

Actual result:
--------------
10

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-02 21:12 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

It is the same scope :-)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Fri Aug 28 17:00:02 2026 UTC