Thank you Halojoy and Drakla
Here is how my final WORKING code looks like (in case someone else wants to use it):
<?php
// Basic Test Class for the Object to be Serialized ---------------
class testClass
{
var $attribute;
var $attribute2;
var $cB;
function set_attribute($a,$b)
{
$this->attribute = $a;
$this->attribute2 = $b;
$this->cB = $a . ", oh beautiful " . $b;
}
function display()
{
echo $this->cB;
}
}
// Creating a New Object and setting a and b values ---------------
$a = new testClass();
$a->set_attribute("Hello", "World");
$a->display();
echo "<br><br>";
echo serialize($a);
// saving Object to text file -----------------------------------------------
$fp = fopen("postData.txt","a");
$data = serialize($a)."<!-- E -->";
fwrite($fp, $data);
fclose($fp);
// reloading from File and output to screen ----------------------------
if (file_exists("postData.txt")) {
$filename = "postData.txt";
$handle = fopen($filename, "r");
$datain = fread($handle, filesize($filename));
fclose($handle);
$out = explode("<!-- E -->", $datain);
$bla = unserialize($out[0]);
echo "<br><u>Retrieved Data</u><br>";
echo $bla->display();
echo "<br>";
$bla = unserialize($out[1]);
echo $bla->display();
}
?>
In case anyone is wondering WHY you would ever need this code, I am going to use this code to create the next version of my Guestbook Script (DigiOz Guestbook 1.7), storing entries into a text data file. By storing entries as objects, it will simplify the storage and retrieval of entries to the guestbook, and will also allow us to easily edit and or delete entries to it.
For more information, feel free to visit (Open Source Code):
http://www.digioz.com/phpscripts.php