Sometimes , we need to write some logging information to a text file in php. The following function takes filename and message as the parameter and logs whatever you pass to the file with date and time.
function logToFile($fileName, $logMessage)
{
$logDirectory = “/path/to/log/dir”;
$fileHandler = fopen($logDir . '/'