how to write data to file in php

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

3 replies · 475 views · started 17 years ago · 1 min read

Guest #1

consider i have a class

 
class STORE
{
public $string;
public $int;
public $boo;
}

now i want to write the same for example

 
 
$obj=new STORE;
$obj->string="some string";
$obj->int=100;
$obj->bool=true;
 
$stream=fopen("file.dat","wb");
fwrite((char*)&$obj,sizeof($obj)); /*this is a c++ code line,i want to convert the code into php */
fclose($stream);

i get an error "cannot convert obj. to string" is there any other way to write objects to a file as we do in c++

Guest #3

i already know how to write data to a file(php's inbuilt functions only supports string and not objects) the thing that i want to know is how to write an instance of a class to a file

Guest #4

never mind i created my own class which i just posted in the Scripts forum named as "Fstream.php"

Sign in to reply.

Similar topics

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