.dsy:it.
Show 150 posts per page

.dsy:it. (http://www.dsy.it/forum/)
- Tech (http://www.dsy.it/forum/forumdisplay.php?forumid=189)
-- [PHP5]object referencing (http://www.dsy.it/forum/showthread.php?threadid=22111)


Posted by fabpicca on 17-10-2005 08:56:

[PHP5]object referencing

Ho il seguente problema.
Ho la necessità di incapsulare un riferimento ad un attributo di un oggetto in un altro oggetto. in questo senso

PHP:

class object1{
   public $attr1;
   public $attr2;
}

class object2{
   ...
   public $referencedObject

   __construct(...,...,...,$_referencedObject){
      $this->referencedObject=$_referencedObject;
   }
}

[myfile.php]
$obj1=new object1(...);
$obj2=new object2(...,...,...,$obj1);

/*----->*/ $obj2->referencedObject->attr1=$someValue;



Il problema è che nonostante il modello ad oggetti di php5 preveda il passaggio per riferimento come comportamento di default (Java style) la chiamata identificata dalla freccia non ha l'effetto sperato di modificare l'oggetto 1, ma le modifiche rimangono ristrette all'oggetto 2. Qualche idea?

__________________
my website?|ubuntu linux|get Firefox|grazie Polonia |bagdad sour

"Come va che non ha le corna e le zampe di Caprone?" gli opposi. "Oh, Giuvà", mi disse il prete "adesso non si usa più.Satana è furbo". (I.Silone, Fontamara)
"Al giorno d'oggi non bisogna essere intelligenti, perchè la gente si offende" (un ubriacone)
"close your eyes / pay the price / for your paradise" (DM) "whatever you want to change/you'd better start changing it in your mind" (Transatlantic)


All times are GMT. The time now is 21:31.
Show all 1 posts from this thread on one page

Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.