From the course: PHP Techniques: Working with Files and Directories

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Create a log file

Challenge: Create a log file - PHP Tutorial

From the course: PHP Techniques: Working with Files and Directories

Start my 1-month free trial

Challenge: Create a log file

(upbeat music) - [Instructor] It's time for a challenge assignment. In this challenge, I want you to take everything we've learned about working with files and directories and PHP throughout this chapter and work to create a log file. The idea is that in an application, you very often want to log some information to a log file. And so we want to write a PHP function that will make that easy. The function might be called something like log underscore action, and you can pass in information to it like the action or a message or both. Then inside that function, everything we need to log to the log file would be included. So all we have to do is call log action and we can log information to our log file. The assignment is fairly open-ended in how you actually accomplish that but I will give you a couple of suggestions and reminders. First, choose a file path for the log file. Where is the log file going to be located?…

Contents