Re: php not reading file properly
| From: | Jochem Maas | Date: | Mon, 25 Aug 2008 12:04:06 +0000 |
| Subject: | Re: php not reading file properly | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-278649@lists.php.net to get a copy of this message | ||
sean greenslade schreef:
Well, if you really want to know, I have to go to many places that do not have internet access. For those places, I have a PDA. I have Avantgo software on the PDA, and I wanted it to be able to store a copy of the log file to review it when I do not have internet access. All I needed was a webpage to access it, and the Avantgo software automatically downloads a copy of it before I leave.I see. :-) I was worried that it was going to cause grief ... people constantly looking at the output of that script would do no good for your servers performance. you must have good eyesight to be reading apache logs on a PDA :-P
On Sun, Aug 24, 2008 at 7:42 PM, Jochem Maas <jochem@iamjochem.com> wrote:sean greenslade schreef: I have this snippet of code that is supposed to read the apache access logand display it: <?php $myFile = "/var/log/httpd/access_log"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); echo "This weeks apache log (clears every sunday morning):". substr($theData,0,2000); ?> For some reason, it displays the logs when I run the php file thru terminal: php -f /web/apache.php but not when I access it thru the web. when I browse to it, it just displays the static text ("This weeks apache log (clears every sunday morning):"), not the log text.you fixed the problem, but I have to ask: why on earth you want to do this?Very confused, zootboy