473,772 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

explicitly destroy Objects in PHP5

Hi,

how do I "explicitly destroy" an Object in PHP5 to make sure the
destructor is called an the object destroyed?

unset is not an option because there are multiple variables containing
the object handle.

Waiting for the end of the script is aswell a bad option because the
order in which the destructores are called does matter.

So what else could be done to "explicitly destroy" the object?
If i simply call __destruct it would be called twice, bad aswell.

Since I have intensively searched the manual I fear there is no C++
like "delete Obj" construct in PHP. I really wonder why this is not
the case since destructors exist and the other OOP features of PHP5
seem really fine.

Any Ideas?

Best Regards
Thomas Ilsche
Jul 17 '05 #1
1 15270
On 18 Apr 2005 07:01:01 -0700, go****@zulan.ne t (Thomas Ilsche) wrote:
how do I "explicitly destroy" an Object in PHP5 to make sure the
destructor is called an the object destroyed?
Remove all references to the object.
unset is not an option because there are multiple variables containing
the object handle.
If you were to explicitly destroy the object than these multiple
variables would reference a destroyed object -- that would not be a
good thing.

The best option is still to remove all the references.
So what else could be done to "explicitly destroy" the object?
If i simply call __destruct it would be called twice, bad aswell.
Use a flag to prevent __destruct from doing anything more the second
time it's called. What is going on in your destructor anyway?
Since I have intensively searched the manual I fear there is no C++
like "delete Obj" construct in PHP. I really wonder why this is not
the case since destructors exist and the other OOP features of PHP5
seem really fine.


C++ doesn't have garbage collection which is why it has delete. PHP
has garbage collection so delete isn't needed.
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2193
by: lawrence | last post by:
Do I understand correctly that in PHP 5.0 objects will be passed by reference (by handle, they say) automatically, not as a copy, as happens with most PHP variables?
5
9498
by: Jan Pieter Kunst | last post by:
(apologies if this message is a duplicate -- my news server seems to have problems) Greetings, When using PHP 4, this: // ex. 1 class A { function A(&$obj) {
1
2277
by: Minkyu Kim | last post by:
Hi. Please check this simple test code. --------------------- class TestA: def __init__(self): print "init TestA" def __del__(self): print "del TestA" def SetEvent(self, event):
8
1951
by: vvenk | last post by:
Hello: I just wrote my first ASP.Net application. It worked fine on my machine and when I put into production, the ASP.Net process reaches 50% quite fast and then the system does not work anymore until I kill that process. Obviously, this is not acceptable. Looking back, I do not destroy any objects in my form. Would that be the reasn why the application breaks down?
16
4552
by: LP | last post by:
Hello, I am trying to use .NET with Excel. I installed Office 2003 and selected ..NET programming suport option, so it installed all those PIA, as MS sugests. But I can not find a way to destroy Excel process, it still hangs in the taks manager' Processes as running. I am trying very simple code (see below), but Excel wont go away, I tried just about anything I could find on MSDN or by Google. Even calling WIN32 API to destroy Excel. But...
2
1474
by: bg_ie | last post by:
Hi, I'm creating objects in my python script belonging to a COM object which I dispatch using win32com.client.DispatchEx. Hence, dllhost.dll is the concerned process. The problem is that the objects destructor within the com object is not called if the object lives past a certain number of seconds. For example, this function will not call the destructor concerned with obj unless the sleep is commented out. def fnction:
9
2373
by: devloop | last post by:
Hi, I am a JAVA developer who just started with php5 (on a WAMPP with php5.2.1). I´ve the following problem with a little class (I wanted to put objects into the array later but even with simple strings it doesn´t work!!!!!!!!!). The output doesn´t show any letters/strings when I call the method toHtml().
4
2032
by: Juergen-Bernhard Adler | last post by:
Hello, pretend some noob has (in a fake-static class) provided the following method public static kill_object($obj) { if (!is_object($obj)) return false;
13
2411
by: DigitalDave | last post by:
A project I did awhile back stored php5 objects in elements of the $_SESSION array between pages that were navigated on the site. There were object classes representing teachers, and object classes representing students that referenced teacher objects. Then I happened to look at the temporary files created by sessions and found much redundant data was stored in each file about the teachers since they were referenced by every student in...
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.