note 96638 deleted from function.file-get-contents by danbrown
| From: | danbrown@php.net | Date: | Tue, 09 Mar 2010 15:52:33 +0000 |
| Subject: | note 96638 deleted from function.file-get-contents by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166831@lists.php.net to get a copy of this message | ||
Note Submitter: jerri at jerri dot de
----
It seems, that file_get_contents always adds an carriage return to the end of a file. The following
simple script produces not the output I expected.
Create a file
echo 'Just a test' > test.txt
Use the following script:
<?php
$string = file_get_contents('test.txt');
echo '"'.$string.'"';
?>
I would have expected
"Just a test"
But the result is
"Just a test
"
This is not a big bug, but can lead to all kind of funny problems.
Using PHP 5.3.1-5 with Suhosin-Patch (cli) (built: Feb 22 2010 17:37:40) und debian.