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
 [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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC