php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43442 __destruct is calling right after __construct
Submitted: 2007-11-28 17:48 UTC Modified: 2008-02-18 01:00 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:4 of 5 (80.0%)
Same Version:4 (100.0%)
Same OS:3 (75.0%)
From: cjshark at mail dot ru Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.2.5 OS: FreeBSD v60
Private report: No CVE-ID: None
 [2007-11-28 17:48 UTC] cjshark at mail dot ru
Description:
------------
__destruct is calling right after __construct before using any methods!

Reproduce code:
---------------
	class test
	 {
	 	function __construct()
	 	 {
	 	 	echo "construct<br>";
	 	 }

  		function method($i)
  		 {
  		 	echo $i."<br>";
  		 }


	 	function __destruct()
	 	 {
	 	 	echo "destruct<br>";
	 	 }

	 }


	$cl = new test();
	$cl->method('method!!');

Expected result:
----------------
construct
method!!
destruct

Actual result:
--------------
construct
destruct
method!!
destruct

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-29 08:03 UTC] derick@php.net
This is not what I'm seeing, I see the correct:

construct<br>method!!<br>destruct<br>
 [2007-11-29 10:39 UTC] jani@php.net
Me too:

$ src/build/php_5_2/sapi/cli/php t.php
construct
method!!
destruct

So what could be wrong with your build / setup? In what SAPI? What configure line was used? What 3rd party extensions are loaded? 
 [2007-11-30 11:00 UTC] cjshark at mail dot ru
I meen everything is ok under php 5.2.3 and less BUT 5.2.5! Nothing else is using (search as 3rd party extensions or smth).
 [2007-12-03 11:14 UTC] jani@php.net
So what is the configure line you used?
 [2007-12-11 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-12-14 17:07 UTC] camelot at plevel dot com
im on FreeBSD v6.2
with php 5.2.5 and zend optimiser 3.3
when i turn on zend
i get this 
construct
destruct
method!!
destruct

when i turn zend off
i get
construct
method!!
destruct
 [2008-02-07 14:22 UTC] info at cvmedia dot de
im on Suse Linux 2.6.22 with php 5.2.5
i get this: 
construct
destruct
method!!
destruct
 [2008-02-10 21:19 UTC] johannes@php.net
Check the state of zend.ze1_compatibility_mode
 [2008-02-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC