Re: Array of Classes

From: Date: Mon, 06 Oct 2003 18:17:40 +0000
Subject: Re: Array of Classes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-165216@lists.php.net to get a copy of this message
On Mon, 6 Oct 2003 13:41:22 -0400, you wrote: >1) How can I create an array of classes so they could be referenced, for >instance: $array[$uniqueID][$class->var] = 10; ? > >2) Would it instantiate when that particular element was used and would the >constructor run at that point? > >3) Any way to dispose/destroy of an object once it's done being used to free >up the resources? <? class A { function A () { echo ("<p>Created</p>"); } function B ($s = "None") { echo ("<p>input : $s</p>"); } } $C = array(); for ($i = 0; $i < 3; $i++) { $C[$i] = new A(); } for ($i = 0; $i < 3; $i++) { $C[$i]->B($i); } for ($i = 0; $i < 3; $i++) { unset ($C[$i]); } ?>

« previous php.general (#165216) next »