how to write data to file in php

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

    how to write data to file in php

    consider i have a class

    PHP Code:
    class STORE
    {
    public 
    $string;
    public 
    $int;
    public 
    $boo;

    now i want to write the same
    for example
    PHP Code:
     
    $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++

    #2
    you can find a tutorial how to use the file write here:
    Advertise your mobile site for FREE with AdTwirl

    Comment


      #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

      Comment


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

        Comment

        Working...
        X