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.

Solution: Create a log file

Solution: Create a log file - PHP Tutorial

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

Start my 1-month free trial

Solution: Create a log file

(upbeat music) - [Instructor] I hope that you were able to come up with a solution for this challenge assignment and that you were able to use PHP to write information to a log file. In this movie, I'm going to show you the solution that I came up with. I created a new PHP file which I called log_action.php which is going to both define the log action function and then I'm also going to use it down below. In a real application, we could call this log_action from a number of different places but I just wanted to test it out. Inside the log_action function, you can see that I'm setting the file path and I set it equal to the current directory where the log_action script is and appended that onto log.txt. That's the file that doesn't exist over here yet but it will be in the same directory. You could put it somewhere else. It doesn't really matter. Then you can see that I'm opening up the file using that file path…

Contents