Location: PHPKode > scripts > Strategy based serializable object registry > strategy-based-serializable-object-registry/drivers/csomething1filedriver.php
<?php
defined(ALLOW_EXEC) or die;
CImporter::getInstance()->import("library","iserializable.php"); 
CImporter::getInstance()->import("library","cobjectregistrydriverbase.php");

class CSomething1FileDriver extends CObjectRegistryDriverBase implements ISerializable{
    public function load(){
        $handle = fopen($this->getRegistry()->getFilePath(),"r");
        while ($userinfo = fscanf($handle, "%s %s %s\n")) {
            list ($keyVal, $equals, $value) = $userinfo;
            //echo $keyVal." ".$equals." ".$value."</br>";
            $this->getRegistry()->set($keyVal,$value);
        }
    }
    public function save(){
        $filename = $this->getRegistry()->getFilePath();
        unset($somecontent);
        $somecontent = "db_host = ".$this->getRegistry()->get('db_host')."\n";
        $somecontent .= "db_user = ".$this->getRegistry()->get('db_user')."\n";
        $somecontent .= "db_pass = ".$this->getRegistry()->get('db_pass')."\n";
        $somecontent .= "db_name = ".$this->getRegistry()->get('db_name')."\n";
        if (!$handle = fopen($filename, 'w')){
        }
        if (fwrite($handle, $somecontent) === FALSE){
        }
        fclose($handle);
    }
};  
?>
Return current item: Strategy based serializable object registry