Richard, OP,
Richard Lynch wrote:
Richard Lynch wrote:
class c2 {
private static $_ref;
public function __construct() {
self::$_ref = new c1();
//$this->_ref = new c1();
}
}
$obj = new c2();
unset($obj);
?>
self::$_ref is completely independent of any instance of that class.
c2::$_ref
> Richard Lynch wrote:
>class c1 {
>>> public function __destruct() {
>>> echo '__destruct';
>>> }
>>>}
>>>
>>>class c2 {
>>> private static $_ref;
>>>
>>> public function __construct() {
>>> self::$_ref = new c1();
>>>
>>> //$this->_ref = new c1();
>>> }
>>>}
>>>
>>>$ob
Richard Lynch wrote:
class c2 {
private static $_ref;
public function __construct() {
self::$_ref = new c1();
//$this->_ref = new c1();
}
}
$obj = new c2();
unset($obj);
?>
i thought this should display __destruct in both cases from
c2::__construct, but only the one with non static
> class c1 {
>public function __destruct() {
> echo '__destruct';
>}
> }
>
> class c2 {
>private static $_ref;
>
>public function __construct() {
> self::$_ref = new c1();
>
> //$this->_ref = new c1();
>}
> }
>
> $obj = new c2();
> unset($obj);
> ?>
>
> i though
Jochem Maas wrote:
Robert Janeczek wrote:
[EMAIL PROTECTED] wrote:
Hi It is an expected behavior because when you define a static
variableit is shared by all objects of the same class. If When you
unset one object and the destruct of the static object will be
called, all the other objects will l
Robert Janeczek wrote:
[EMAIL PROTECTED] wrote:
Hi It is an expected behavior because when you define a static
variableit is shared by all objects of the same class. If When you
unset one object and the destruct of the static object will be
called, all the other objects will lose the static var
[EMAIL PROTECTED] wrote:
Hi It is an expected behavior because when you define a static
variableit is shared by all objects of the same class. If When you
unset one object and the destruct of the static object will be
called, all the other objects will lose the static var as well.
yes, but why d
yaron
-Original Message-
From: Robert Janeczek [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 10, 2005 1:28 PM
To: php-general@lists.php.net
Subject: [PHP] destructor not called for static members?
am i missing something or destructor isn`t called for objects that are
assigned to static fields in
am i missing something or destructor isn`t called for objects that are
assigned to static fields in other objects? here is some example code:
class c1 {
public function __destruct() {
echo '__destruct';
}
}
class c2 {
private static $_ref;
public function __construct() {
self::$_
9 matches
Mail list logo