Home  >  Article  >  Backend Development  >  How to write newline to file in php

How to write newline to file in php

hzc
hzcOriginal
2020-07-04 13:40:375764browse

The method for php to write a newline to a file is: 1. Add "\r\n" after the variable [$filename]; 2. Write [file_put_contents($filelist, $filename) in the code "\r\n", FILE_APPEND)] function.

How to write newline to file in php

The way PHP writes files with line breaks

It is not possible to add "\r\n" directly after the string;

Just add ."\r\n" after writing variable $filename

file_put_contents($filelist, $filename."\r\n",FILE_APPEND);

Related introduction:

PHP is "hypertext preprocessor" and is a general open source scripting language. PHP is a scripting language executed on the server side. It is similar to C language and is a commonly used website programming language. PHP's unique syntax mixes C, Java, Perl, and PHP's own syntax. It is conducive to learning and widely used. It is mainly suitable for the field of web development.

PHP was originally the abbreviation of Personal Home Page and has been officially renamed "PHP: Hypertext Preprocessor". Since the domestic Internet began to develop in the 1990s, Internet information has covered almost all areas of knowledge in our daily activities, and has gradually become an indispensable part of our lives, studies, and work. According to statistics, since 2003, the size of my country's web pages has basically maintained a doubling growth rate, and is showing an upward trend. As the most popular website program development language today, PHP language has the advantages of low cost, fast speed, good portability, and rich built-in function libraries. Therefore, it is used by more and more companies in website development. However, with the continuous upgrading of the Internet, many problems have arisen in the PHP language.

According to the requirements of dynamic websites, PHP language, as a language program, its specificity gradually appears in the application process, and its technical level will directly affect the operating efficiency of the website. Its characteristics are that it has an open source code and is highly similar to general-purpose languages ​​such as C language in terms of programming. Therefore, it is easy to understand and has strong operability during operation. At the same time, the PHP language has a high level of data transmission, processing and output, and can be widely used in Windows systems and various types of Web servers. If the amount of data is large, the PHP language can also broaden the link surface and connect to various databases to alleviate the pressure of data storage, retrieval and maintenance. With the development of technology, PHP language search engines can also be tailored to provide personalized services, such as classifying, collecting and storing data according to customer preferences, which greatly improves data operation efficiency.

Recommended tutorial: "php tutorial"

The above is the detailed content of How to write newline to file in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn