Use PHP_EOL
which produces \r\n
or \n
$data="my data" . PHP_EOL . 'my data';
$fp = fopen('my_file', 'a');
fwrite($fp, $data);
fclose($fp);
// File output
my data
my data
More Related Contents:
- How to get static data member from php object instance? [closed]
- Php date() Date and time is stuck [closed]
- Are PDO prepared statements sufficient to prevent SQL injection?
- Preventing Directory Traversal in PHP but allowing paths
- What is the best IDE for PHP? [closed]
- Using PHP with Socket.io
- Is it possible to overwrite a function in PHP
- Diagnosing Memory Leaks – Allowed memory size of # bytes exhausted
- Laravel migration: unique key is too long, even if specified
- Which $_SERVER variables are safe?
- Laravel Eloquent select all rows with max created_at
- PDO error: ” SQLSTATE[HY000]: General error ” When updating database
- Advantages Of MySQLi over MySQL [closed]
- What is the difference between self::$bar and static::$bar in PHP?
- How to get all combinations from multiple arrays?
- Regex to detect invalid UTF-8 string
- PHP mail: Multiple recipients?
- How to pass a Javascript Array via JQuery Post so that all its contents are accessible via the PHP $_POST array?
- WAMPServer phpMyadmin Maximum execution time of 360 seconds exceeded
- Session unset, or session_destroy? [duplicate]
- Remove domain extension
- Send cookie with file_get_contents
- Disabling Strict Standards in PHP 5.4
- unit testing and Static methods
- Displaying a Base64 images from a database via PHP
- PHP Spread Syntax in Array Declaration
- show progressbar while loading pages using jquery ajax in single page website
- How to decode a JSON String with several objects in PHP?
- HTML 5 multi file upload with PHP
- 500 Internal Server Error?