This a Fstream class that i wrote which can be used to read and write objects to a file
this class is not available in any other language except in c++ and now in PHP
limitations :cannot write objects having arrays
example :
enjoy!
this class is not available in any other language except in c++ and now in PHP
limitations :cannot write objects having arrays
example :
PHP Code:
<?php
//write example
include("fstream.php");
class user
{
public $username;
public $password;
}
$record=new user;
$record->username="userone";
$record->password="pass";
$stream=new fstream;
$stream->write($record,"obj.txt","ab"); //append binary
?>
PHP Code:
<?php
//read example
include("fstream.php");
class user
{
public $username;
public $password;
}
$record=new user;
$stream=new fstream;
$stream->read("obj.txt"); //read the file
$stream->getrecord($record,0); //here 0 is the record number if record was not found false is returned
echo $record->username; //ouput:userone
echo $record->password;//output:pass
?>