Dynamic Class Name Assignments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All, im new to classes in PHP. Im trying to create
several instances of a very basic class but i want
each name to be based on number values in an array and
im not sure if it is allowed and if so how to do it. I
assume that im not allow to have a var starting with a
number so what i am trying to do is add the word case
to the front of the class instance name so i would
have $case100,$case101 etc. Im am using PHP 5.02.
Heres my code

<?php

class Test
{
//members
	var $caseid,$fee;
	
	function Test($caseid){
	$this->caseid=$caseid;
	}
	
	function addmember($membername,$value){
		$this->$membername=$value;	
	}
}

$names=array("100","101","102","104");
$numnames=count($names);
for($i=0;$i<$numnames;$i++){
   *** below is the syntax im missing ***
   $case.$names[$i] = new Test($names[$i]);
}
var_dump($case100);
?>

Thanks for any help in advance!

Cheers 

Bob Pilford


	
	
		
___________________________________________________________ 
ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux