Jump to content

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

Your write method is using a variable $updated_contents but it is not getting that variable from anywhere. You need to either pass the variable to the method when you call it or set a class variable and have the method call that. The former is probably what you're looking for.
Link to comment
https://forums.phpfreaks.com/topic/11558-write-file-class/#findComment-43689
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.