Jump to content

Write File Class


Cell0518

Recommended Posts

Hi,
I'm setting up a class to read and write to a file. The code I've posted is trimmed to only include the needed code (both the classes and config files are "included" in a broad "main" file)

*Moved code due to Safety script "403"ing...
[a href=\"http://ftp.chrisloveonline.com/config.phps\" target=\"_blank\"]http://ftp.chrisloveonline.com/config.phps[/a]

At this point, when I have it read, it gets nothing.

Help would be appreciated,
Chris
Link to comment
https://forums.phpfreaks.com/topic/11558-write-file-class/
Share on other sites

Have you changed:
$contents = fread($handle, filesize("$this->filename"));
to:
$contents = fread($handle, filesize($this -> filename));

Also, the read method doesn't return anything. You need to put [code]return $contents[/code] at the bottom of it. Then calling $c = $config -> read(); will have whatever $contents is.
Link to comment
https://forums.phpfreaks.com/topic/11558-write-file-class/#findComment-43660
Share on other sites

well, I added a var $updated-contents; in the class

(i'm continuing to update the file in the 1st post)

I also have it returning the postMessage. It is returning a bad, I can't update the file message, but It's still saving as a blank file.

Thanks for you help,
Chris
Link to comment
https://forums.phpfreaks.com/topic/11558-write-file-class/#findComment-43700
Share on other sites

just adding var $updated_contents won't help anything. First you need to set the variable either somewhere in the class using $this -> updated_contents = 'blah'; or outside the class using $config -> updated_contents = 'blah'; then in your write method you need to access it using $this -> updated_contents or $uc = $this -> updated_contents

Sorry for the late reply, I got dinner
Link to comment
https://forums.phpfreaks.com/topic/11558-write-file-class/#findComment-43738
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.