Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with date #7

Open
B0bbyD0llar opened this issue May 13, 2016 · 1 comment
Open

Error with date #7

B0bbyD0llar opened this issue May 13, 2016 · 1 comment

Comments

@B0bbyD0llar
Copy link

Hello,

i have tested your example and i get an error.

my code

$logFile = 'log/app.log';
$reader = new LogReader($logFile);

foreach ($reader as $log) {
    echo sprintf("The log entry was written at %s. \n", $log['date']->format('Y-m-d h:i:s'));
  }

My Logfile has 45 entries.

i get this error:
Call to a member function format() on null at line echo sprintf("The log entry was written at %s. \n", $log['date']->format('Y-m-d h:i:s'));

@osavchenko
Copy link

Try it like:

foreach ($reader as $log) {
    if (!empty($log) {
        echo sprintf("The log entry was written at %s. \n", $log['date']->format('Y-m-d h:i:s'));
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants