Fstream.php

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Fstream.php

    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 :
    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
    ?>
    enjoy!
    Attached Files
    Last edited by Guest; 14.04.09, 14:32. Reason: 0 instead of 1
Working...
X