Ninjakreborn Posted April 10, 2007 Share Posted April 10, 2007 1. What is serialize, de-serialize and do I need to worry about getting into those? 2. I finally found out what output buffering is for, and how it works. Is it worth using for anything? Link to comment https://forums.phpfreaks.com/topic/46420-solved-2-questions/ Share on other sites More sharing options...
trq Posted April 10, 2007 Share Posted April 10, 2007 1. serialize, unserialize. 2. It has its purposes. Link to comment https://forums.phpfreaks.com/topic/46420-solved-2-questions/#findComment-225806 Share on other sites More sharing options...
wildteen88 Posted April 10, 2007 Share Posted April 10, 2007 serialize is good for storing an array in a single database table/cookie or any other form of storage. Sessions get their data serialize. If you want to use the serialized data then you can use unserialize, to un-serialize the data. Example (Using a Cookie): <?php if(!isset($_COOKIE['test'])) { // some dummy data will do $data = array('username' => 'foobar', 'age' => 50); // serialize the data to be stored in the cookie // The serialized string: // a:2:{s:8:"username";s:6:"foobar";s:3:"age";i:50;} $cookie_data = serialize($data); // set the cookie setcookie('test', $cookie_data, time()+3600); echo '<a href="?p=2">Get the cookie!</a>'; } else { echo 'Get the cookie:<br /><br /> Cookie recieved (<i>serialized string</i>):<br />' . $_COOKIE['test'] . '<br /><br />'; echo 'Unserialize cookie:<br /><br />'; $test_cookie = unserialize($_COOKIE['test']); echo 'Cookie unserilized<br /><br />Contents of cookie: <pre>' . print_r($test_cookie, true) . '</pre>'; } ?> Output buffering is good for creating a cache. heres a good tutorial that creates a basic cache. Link to comment https://forums.phpfreaks.com/topic/46420-solved-2-questions/#findComment-225922 Share on other sites More sharing options...
Ninjakreborn Posted April 10, 2007 Author Share Posted April 10, 2007 Ah perfect, thanks. Now I can see why Code Igniter has the cache system. I was wondering how that worked, where they cache some information into the system to make it skip a bunch of processes. Thanks for the tutorial. Link to comment https://forums.phpfreaks.com/topic/46420-solved-2-questions/#findComment-225934 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.