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 - PHP Tutorial
From the course: PHP Techniques: Working with Files and Directories
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
-
-
-
(Locked)
Filesystem basics6m 6s
-
Relative paths and magic constants4m 53s
-
(Locked)
Accessing files5m 4s
-
(Locked)
Reading from files4m 52s
-
(Locked)
Reading line by line5m 9s
-
(Locked)
File permissions5m 34s
-
(Locked)
Writing to files5m 5s
-
(Locked)
Writing line returns2m 28s
-
(Locked)
Deleting files2m 38s
-
(Locked)
Moving the file pointer7m 36s
-
(Locked)
Examining file details6m 52s
-
(Locked)
Challenge: Create a log file2m 2s
-
(Locked)
Solution: Create a log file3m 17s
-
(Locked)
-
-
-