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

Writing line returns - PHP Tutorial

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

Start my 1-month free trial

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