Hello!
Thanks to your help, I wrote a small php script using fopen (...,'a'); fwrite and fclose to write the IP address of visitors to my web site into a text log file.
viewtopic.php?f=1&t=93484&p=511298#p511298
Its been working great but now my file is approaching 200K.
My question for your theorists is....is there a cost to having php open and append text files when they get large? Will it slow down my site or can I just continue on as the thing gets up to a few MB?
- thanks
Burden to open and append text file with fopen
Moderator: General Moderators
Re: Burden to open and append text file with fopen
Creating a handle is relatively inexpensive. Seeking a couple times is inexpensive, but lots of seeking would be expensive. Reading small amounts of data would be inexpensive reading large amounts would be expensive. Same with writing small amounts of data. appending involves creating a handle, seeking 1x to the end of the file, and then writing some data and closing a handle.
Re: Burden to open and append text file with fopen
If all you are doing is appending, I'd be tempted to just do:
Code: Select all
shell_exec("echo " . escapeshellarg($ipAddress) . " >> /path/to/file.txt");