php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43335 Unset $this inside a method
Submitted: 2007-11-19 12:29 UTC Modified: 2007-11-19 13:16 UTC
From: felipensp at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3CVS-2007-11-19 (snap) OS:
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: felipensp at gmail dot com
New email:
PHP Version: OS:

 

 [2007-11-19 12:29 UTC] felipensp at gmail dot com
Description:
------------
Manual says:
"Note: It is not possible to unset $this inside an object method since PHP 5."

Reproduce code:
---------------
<?php

class foo {
  public function __construct() {
    unset($this);
    var_dump($this);
  }
}

new foo;

Expected result:
----------------
object(foo)#1 (0) {
}


Actual result:
--------------
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-19 13:16 UTC] jani@php.net
It means it doesn't have any effect except inside that method..
And this isn't any different from how it works in 5.2 -> bogus.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 10:01:29 2025 UTC