php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72886 unset a property on object
Submitted: 2016-08-18 20:51 UTC Modified: 2016-08-18 22:00 UTC
From: nikolaspinasco at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: Irrelevant OS: ubuntu
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: nikolaspinasco at gmail dot com
New email:
PHP Version: OS:

 

 [2016-08-18 20:51 UTC] nikolaspinasco at gmail dot com
Description:
------------
When I try unset() a property on object not instanced this remove a first proporty, please check the script.

Test script:
---------------
$object = new stdClass();
$object->test = '1'; 
$object->test_unset = '2';

var_dump($object);
$object2 = $object;
unset($object2->test_unset);
var_dump($object); 



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-18 22:00 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2016-08-18 22:00 UTC] nikic@php.net
Objects don't use by-value semantics. If you want to clone an object, use "$object2 = clone $object".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Mar 11 11:01:31 2025 UTC