Reply to Re: get object value

Your name:

Reply:


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-)

[Back to original 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

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