|
Posted by IchBin on 12/17/81 11:55
Mike Zhang wrote:
> Thanks,
> It seems working now.
>
> mz
>
> "ImOk" <jon.macaroni@gmail.com> wrote in message
> news:1155526113.891004.203830@m79g2000cwm.googlegroups.com...
>> Did you even run this code? Your code is full of syntax and runtime
>> errors. Here is the fixed up version.
>>
>> <?php
>> Class Shop{
>> var $mID;
>> var $mName;
>>
>> function setID( $id ){
>> $this->mID=$id;
>> }
>>
>> function getID(){
>> return $this->mID;
>> }
>>
>> function setName( $name ){
>> $this->mName=$name;
>> }
>>
>> function getName(){
>> return $this->mName;
>>
>> }
>> }
>>
>> function makelist( ){
>> $vector=array();
Not sure how you can say that this works. Yes this will generate 10
instances of the "same thing". You need to move the $aShop = new Shop();
into your loop. This will then generate the 10 instances but the data in
the instances will be different.
>> for( $i=0;$i<10;$i++){
$aShop = new Shop();
>> $aShop->setID($i);
>> $aShop->setName("shopname".$i);
>> $vector[]=$aShop;
>> }
>> return $vector;
>> }
>>
>> $shoplist = makelist();
>>
>> for( $j=0;$j<10;$j++){
>> echo "ID: " . $shoplist[$j]->getID()."Name:
>> ".$shoplist[$j]->getName();
>> }
>>
>> ?>
>>
>
>
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Navigation:
[Reply to this message]
|