473,413 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

PHP Constructors and Destructors

darksteel21
Hi to all...
I would just like ask about this codes :
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. class MyDestructableClass {
  3.    function __construct() {
  4.        print "In constructor\n";
  5.        $this->name = "MyDestructableClass";
  6.    }
  7.  
  8.    function __destruct() {
  9.        print "Destroying " . $this->name . "\n";
  10.    }
  11. }
  12.  
if you make a new instance of this class and after using it will it automatically destroy its instance or call its function __destruct()?how do we destroy the instance of class in PHP??
Jul 29 '08 #1
2 1027
r035198x
13,262 8TB
You don't call it yourself. It's called automatically as soon as all references to that object are no longer existing.
Jul 29 '08 #2
pbmods
5,821 Expert 4TB
Heya, Darksteel.

You can delete a reference by using PHP's unset() function (http://php.net/unset).
Jul 29 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Rajesh Garg | last post by:
Can we have private constructors and destructors? IF yes what is the use of such constructors or destructors.....in the sense where can these be implemented in a system................. I have...
4
by: François Duranleau | last post by:
Hi! I was writing some piece of code and then, after pondering on some readings in "More Effective C++" by Scott Meyers (Item 10) and the book of Stroustrup (section 14.4.1 in the hardcover...
3
by: Amit | last post by:
is there anything like static constructors or destructors in C++ ? if yes, how to implement it? Thanks, Amit.
3
by: rahul8143 | last post by:
hello, I write a following program and have problem in understanding constructors and destructors. #include <iostream.h> class vector { public: double x; double y;
4
by: rahul8143 | last post by:
hello, i want to know that is virtual constructors possible? if not why? also does virtual destructors functions are often used in C++ programming. regards, rahul.
5
by: ElanKathir | last post by:
Hi All ! I want to know about the constructors & Destructors, constructors ---> New Destructors --> What ? (Which keyword to use for Destructor) Thanks & Regards, ElanKathir.S.N, ASM...
5
by: Alok | last post by:
hii Would somebody clear my doubts on following qustions . What are virtual constructors and virtual destructors ? Why can't we have virtual constructors ? What are demerits of inheritence in...
2
by: phyburn | last post by:
I need help understand what constructors and destructors do. I am reading my book and I just can't understand why they are in this program. Here is the code to the program the first set up code is...
21
by: Michael Hull | last post by:
Hi, I remember from somewhere reading that inlining constructors is a 'BadThing', but now can't seem to find the original source. I can't however thing of a reason why it would be for simple...
3
by: avinash6174 | last post by:
I could complie my code in one directory and the same piece of code in the other directory I couldnt complie the code.. I am working on the same machine .. Its giving an eror saying as...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.