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.
Writing line returns - PHP Tutorial
From the course: PHP Techniques: Working with Files and Directories
Writing line returns
- [Instructor] We need to discuss how to write line returns to your files using PHP. Different operating systems use different standards for line returns. In Unix and MacOS, a line return is represented by a backslash and the letter N. In PHP, you want to always use double quotes with it so that it has its special meaning as a line return. In Windows however, it is \r\n, two special characters together. This convention goes all the way back to the beginning of DOS and has caused a lot of headaches over the years. Recently, it has begun to change a little. Notepad now supports both and Windows can use Linux as a sub-system, which also uses \n. So maybe it will change, but for now we need to be mindful of this difference. Let's demonstrate line returns in the file_write.php page that we created in the last movie. I'm going to start by just going right up here and making some notes that Unix/Mac new lines are \n and…
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)
-
-
-