Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] __wakeup
no-scared
post
Post #1





Grupa: Zarejestrowani
Postów: 112
Pomógł: 0
Dołączył: 24.04.2008

Ostrzeżenie: (0%)
-----


  1. <?php
  2.  
  3. $x = new klasa();
  4.  
  5. $y = serialize($x);
  6. $z = unserialize($y);
  7. var_dump($z); // NULL
  8. $h = unserialize(serialize($x));
  9. var_dump($h); // NULL
  10.  
  11. class klasa
  12. {
  13. public $sleep;
  14. public $wakeup;
  15. function __sleep()
  16. {
  17. $this->sleep = 'sleep';
  18. echo $this->sleep;
  19. }
  20. function __wakeup()
  21. {
  22. $this->wakeup = 'Deserializacja...';
  23. echo $this->wakeup;
  24. }
  25. }
  26.  
  27. ?>


dlaczego tam gdzie pokazałem w komentarzach jest wartosc NULL? zle zrozumialem koncepcje __wakeup? ze __sleep działa dobrze... moglbym moze jakis przyklad korzystania z __wakeup?


yghh... wyczytalem w manualuy ze __sleep ma zwracac tablice ale nie kapuje tablice czego (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) ?

Ten post edytował no-scared 30.06.2008, 14:42:05
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


Nie wiem jak ty to uruchamiasz, ale na 5.2 mam
Kod
sleep

Notice:  serialize() [function.serialize]: __sleep should return an array only containing the names of instance-variables to serialize in /services/www/fake/www/temp/wake.php on line 4

NULL
sleep

Notice:  serialize() [function.serialize]: __sleep should return an array only containing the names of instance-variables to serialize in /services/www/fake/www/temp/wake.php on line 7

NULL


jak dodam te tablice do zwracania to juz jest OK
Go to the top of the page
+Quote Post
no-scared
post
Post #3





Grupa: Zarejestrowani
Postów: 112
Pomógł: 0
Dołączył: 24.04.2008

Ostrzeżenie: (0%)
-----


tak, wlasnie sie dowiedzailem ze __sleep ma zwracac tablice... jeszcze proszę o nie zamykanie tematu
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #4





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


return array( 'sleep', 'wakeup' );
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 14.09.2025 - 21:54