You are here: Array of Instances Inside Constructor « PHP Programming Language « IT news, forums, messages
Array of Instances Inside Constructor

Posted by phpdevkit on 02/11/07 01:32

Can anyone help me figure out how to make a class keep an array of all
of its instances? This was my first and obvious first shot...

class A
{
function A()
{
static $a = array() ;
$this->array =& $a ;

$this->array[] =& $this ;
}
}

But, if I make changes to the instance contents (not included above)
they are lost when I eventually try to use the array of references.
>From what I have read, it is not possible to use a reference to $this
like this because of when memory is actually created by PHP. (It's no
problem if I want to store an array of references AFTER the new
operator has returned the instance but I am trying to make it
transparent and put all of this inside the constructor where it should
be.)

Any tricks or workarounds are appreciated!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация