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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Apr 19 06:01:29 2024 UTC