/** * Gets the last line from the current log file. * * @param bool $thisSession (Optional) Whether the log should be from * the current session only. * @return string|bool A string containing the last log line. * False if the log file is empty or unreadable. */ public static function getLastLog($thisSession = false) { if ($thisSession) { return self::$lastLog; } elseif (!$thisSession) { $logFileContent = Log::logRead(); $logFileContentArray = @explode(PHP_EOL, $logFileContent); if (count($logFileContentArray) != 0) { // Last line is empty due to fwrite() and the next one is the one we need. return $logFileContentArray[count($logFileContentArray) - 2]; } else { return false; } } else { return false; } }