how to make php can read log file in /var/log/….
I tried this code but not work
<?php
$file = "/var/log/smsd.log"; //gammu's sms log
$data = file($file);
$end = count($data);
$first = $end-10;
$number = range($first,$end);
foreach($number as $n) {
$log_data .= $data[$n]."\n";
}
echo $log_data;
?>
But, It is work if i try to read file in same folder with this script.
“but not work” is not an error message. Check you’re configuration has error reporting enabled..
Most likely it’s a permissions issue. How you fix this depends on your operating system and how you manage your log files (but you’ll probably find the answers in the chmod and logrorate man pages).
BTW, your code will also fall over if it has to read very large files. Consider using