php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17900 Unset() for function and class namespace
Submitted: 2002-06-21 10:51 UTC Modified: 2015-12-25 12:46 UTC
Votes:8
Avg. Score:4.4 ± 0.9
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (40.0%)
From: Sky at quit-clan dot de Assigned: cmb (profile)
Status: Closed Package: *General Issues
PHP Version: 4.2.1 OS: Any
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: Sky at quit-clan dot de
New email:
PHP Version: OS:

 

 [2002-06-21 10:51 UTC] Sky at quit-clan dot de
This is another Feature request for special script parsing:

Currently there is the possibility to unset() variables.

But i want the option to clear the function/class namespace, too. A call like

unfunction('foobar');

sould make a redefine of function foobar() in eval()'d code possible, for example. Same thing for classes.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-21 10:53 UTC] derick@php.net
uhm? this sounds like a VERY bad idea to me... and very clumsy programming.
 [2002-06-21 11:08 UTC] Sky at quit-clan dot de
ok, i got answers like this a thousand times.

i am using php to write a console script. it should be able to dynamically load "modules" like DLLs under windows. These modules are, of course, coded in php and contain classes.

the first time when such a module is executed by "eval" all classes in it are defined in class namespace, everything is fine.

now i want to unload the module - who would i undefine it's class?
even if i didn't use classes - functions can't be undefined, either.

any other suggestions of how to implement a "DLL" like system? the only solution i can think of was encapsulating a general module in an class, instanciating it for every module i load, and call it's functions by the objects interface. but this will disable me from directly calling methods in my module...

i know this sounds weird, but php is such a flexible language, it should be able to load functions/objects dynamically!! this would be great.
 [2002-06-21 12:17 UTC] mfischer@php.net
I think you should bring this up on the engine2@lists.php.net . In the past I had also the same reasons for it (dynamic remote code updating with PHP-GTK, etc.) but this won't be implemented just because of a few feature requests.

I think the main problem is that "making it work" far exceeds the benefits over the time it takes to implement so we'll just have to forget it (imho).

Suspending.
 [2002-06-21 12:17 UTC] mfischer@php.net
It's engine2@lists.zend.com , sorry
 [2009-07-19 19:01 UTC] clairaudiant at gmail dot com
couldn't you loop through the $classarray and unset each $key => $value 
of the array?

foreach ( $class as $key => $value ) {
 unset($class[$key])
}

that should fully obliterate reference to the class.  i think
 [2015-12-25 12:46 UTC] cmb@php.net
-Status: Suspended +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: cmb
 [2015-12-25 12:46 UTC] cmb@php.net
The runkit extension[1] provides respective features, so I'm
closing this request.

[1] <http://php.net/manual/en/book.runkit.php>
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 05:01:33 2025 UTC