Skip to content
Advertisement

How to create a logfile in php

I want to create a logfile for my system to register/log every action they do inside the system. But I have no idea how to do it.

For example, I have this php code that does the login function.

JavaScript

now I want to create a logfile entitled ‘the date today’, then when that functions is used for loging in, it will write that user has logged in, the same with other functions. But I only want a single file for every day.

Could anyone be kind enough to guide and teach me how I should do my codes?

Advertisement

Answer

To write to a log file and make a new one each day, you could use date("j.n.Y") as part of the filename.

JavaScript

So you would place that within your hasAccess() method.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement