jaśniej się nie wyraźę, to max moich zdolności lexykalnych

Może kod:
<?php class o_Csesion{ public $counter; function __construct(){ $this->counter=0; } public function start(){ } } function save(){ } function restore(){ $this->counter=$temp->counter; //MERITUM //a jakby sie dało tak: //$this=unserialize($_SESSION['o_Csesion']); // //ale sie nie da? // } .\" razy.\"; } } ?>
Dzięki!
Edit (05-08-2008):
Wygrzebałem odpowiedź do tego problemu, wiec odpisuje na swojego posta w celu info. Domyślam się dlaczego nikt mi ni odpisał. Pewnie jest wielu sfrustrowanych, bo musieli przepisać lub poprawić skrypty napisane na php4:
W php5 $this już nie jest "mutable". Nie można go do niego przypisać innego obiektu tej samej klasy. Wogóle, że dało się w php4, to był przypadek, bo nigdy celowo nie zaimplementowano takiego przypisania i nie zostało ono udokumentowane. Podkreśla to bug-eliminator na stronie: http://bugs.php.net/bug.php?id=27659 .
Dowcipy w kontekscie:
Cytat
This works in php 4. Perhaps this is a feature change but
I could not find a reference to any alternatives so I am
submitting a bug just in case.
I could not find a reference to any alternatives so I am
submitting a bug just in case.
...to ze strony bug-reprot...
Cytat
There is a _LOT_ of code out there using that. Metabase
among others. Is there an alternative? This could be a
huge problem if there is none.
...
How Silly. We used $this for just about every result set in a db query.
We have like a hundred applications. I just ran a sript on our whole
htdocs directory and changed them all to $result.
among others. Is there an alternative? This could be a
huge problem if there is none.
...
How Silly. We used $this for just about every result set in a db query.
We have like a hundred applications. I just ran a sript on our whole
htdocs directory and changed them all to $result.
... a njfajniejsze:
Cytat
Actually this is expected behavior. We explicitly decided to have $this
being readonly because of interna problems with the new engine.
being readonly because of interna problems with the new engine.
...to akurat od szefa wszyskich szewow.
Przykładowe workaround'y:
Oto potencjalne rozwiązanie. Tam gdzie chcesz przypisać coś do $this, zrób tak:
<?php $this->Object = new Whatever(); ?>
Albo, odserializowując dane sessji:
<?php ?>
Teraz jest wybór: raz - oddelegowanie każdej metody, która musi zostać oddelegowana.
Więc, $this przydałaby się metoda dla każdej metody w $Object. Każda z metod mogłaby
przypominać coś jak to:
<?php function nameOfFunction() { return $this->Object->nameOfFunction(); } ?>
Jeden workarołnd jest w pierwszym poście, ale można go jeszcze ulepszyć:
<?php $this = $foo; will something like this: foreach (get_object_vars($foo) as $key => $value) $this->$key = $value; ?>
Jeszcze jest coś z użyciem __set(), __get(), __call()...
Jeśli ktoś na jakie lepsze obejście to proszę, temat otwarty.
Jeszcze jak to sie robi w osCommerce:
http://kb.siteground.com/article/oscommerc...ssign_this.html
</a href=index.php>
<?php includes/classes/upload.php. On Windows/IIS5/ISAPI. Resolwed by commenting: // self destruct // $this = null; Worked at PHP4 Good Luck! ?>