Fstream.php

Started on the old forum in April 2009 · view the original in the archive · old links redirect here

No replies · 791 views · started 17 years ago · 1 min read

Guest #1

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
//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
//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!

Attachments: FSTREAM.zip

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close