RE: [PHP] __construct __destruct in PHP 4
| From: | Richard Lynch | Date: | Tue, 30 Jan 2007 00:07:23 +0000 |
| Subject: | RE: [PHP] __construct __destruct in PHP 4 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247976@lists.php.net to get a copy of this message | ||
PEAR has a bunch of backwards compatibility hacks, and I suspect this
might be already done there in one of those...
On Sun, January 28, 2007 8:17 am, Peter Lauri wrote:
> Hi,
>
> Yes I have been reading both sections and is aware of the different
> sections
> for PHP 4 and 5. I was just hoping there was something missing in the
> manual
> for PHP 4 as I'd love to have a __destruct method to work with. There
> are
> other solutions around this. Basically I just want to make sure that
> the
> objects that have a save() method are saved correctly before they are
> destroyed. With PHP 4 I just need to do this "manually". I could
> probably
> just write a cleanup function that will be executed in the end of each
> scripts that checks if objects have a save() method and then executes
> that
> one. Or better: Check if there is a method __destruct() existing and
> use
> that when cleaning up. Then it would be forward compatible with PHP 5
> as
> well :)
>
> Best regards,
> Peter Lauri
>
> www.dwsasia.com - company web site
> www.lauri.se - personal web site
> www.carbonfree.org.uk - become Carbon Free
>
>
> -----Original Message-----
> From: Larry E. Ullman [mailto:LarryUllman@DMCInsights.Com]
> Sent: Sunday, January 28, 2007 4:09 PM
> To: Peter Lauri
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] __construct __destruct in PHP 4
>
>> I have been trying going thru the PHP manual to find if there are
>> any
>> equivalent to the __contruct and __destruct in PHP 4, but I cannot
>> find any
>> solution for this part. I know it was introduced in PHP 5, but as
>> __sleep
>> and __wakeup exist in PHP 4 already I was hoping there is something
>> like
>> __init and __die in PHP 4 :-)
>
> In PHP 4 the constructor has the same name as the class (like C++).
> See
> http://us3.php.net/manual/en/language.oop.constructor.php
>
> There is no destructor in PHP 4.
>
> Larry
>
> PS The manual has two sets of OOP documentation: one for PHP 4 &
> another for PHP 5. Make sure you're viewing the right set.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?