Edit report at https://bugs.php.net/bug.php?id=65664&edit=1

 ID:                 65664
 Updated by:         ni...@php.net
 Reported by:        valentiny510 at yahoo dot es
 Summary:            __destruct act different when instantiate class
                     with/out var
-Status:             Open
+Status:             Not a bug
 Type:               Feature/Change Request
 Package:            Class/Object related
 Operating System:   Secret :)
 PHP Version:        5.4.19
 Block user comment: N
 Private report:     N

 New Comment:

The destructor is called when where are no more references to an object. In 
case of a temporary value (just new Html that isn't assigned) this will happen 
right after the expression is evaluated.


Previous Comments:
------------------------------------------------------------------------
[2013-09-12 22:48:59] valentiny510 at yahoo dot es

Description:
------------
When the class is instantiated with a variable is working like one espect...
but the issue come when you want to miss the variable, because you don't use it 
or whatever reason..

Can be possible to act the same way both times ?

Examples below..

Test script:
---------------
<?php
class Html
{
    function __construct( ) { echo "Header\n"; }
    function __construct( ) { echo "\nFooter"; }
}

# without variable
new Html;
<p>Some html here...</p>

# with $html var...
$html = new Html;
<p>Some html here...</p>


Expected result:
----------------
Header
Some html here...
Footer

Header
Some html here...
Footer


Actual result:
--------------
Header
Footer <-- This is the problem...
Some html here...

Header
Some html here...
Footer



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65664&edit=1

Reply via email to