Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
backend
php
oop
classes_objects
91magic_sleep_wakeup2.php
91magic_sleep_wakeup2.php
<?php class MojaKlasa { public $a='Publik '; private $c='Priv '; public function ispis() { echo $this->a."<br/>"; echo $this->c."<br/>"; } public function __sleep(){ unset($this); //unistavanje objekta echo 'Pozvana sleep magic metoda.Objekt je obrisan iz memorije sa unset()<br/>'; return array('a','c'); //obavezno staviti } public function __wakeup(){ echo 'Pozvana wakeup magic metoda.<br/><hr/>'; } } //defininranje objekta $obj=new MojaKlasa; //serialization - pretvaranje objekta u string $s_obj $s=serialize($obj); echo $s."<hr/>"; //unserialization - pretvaranje stringa nazad u objekt $obj=unserialize($s); $obj->ispis(); ?>
Reload page
Preview
W3C validation
Edit Code