note 96638 added to function.file-get-contents

From: Date: Tue, 09 Mar 2010 15:40:01 +0000
Subject: note 96638 added to function.file-get-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-166830@lists.php.net to get a copy of this message
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. ---- Server IP: 212.124.37.9 Probable Submitter: 87.238.139.208 ---- Manual Page -- http://www.php.net/manual/en/function.file-get-contents.php Edit -- https://master.php.net/note/edit/96638 Del: integrated -- https://master.php.net/note/delete/96638/integrated Del: useless -- https://master.php.net/note/delete/96638/useless Del: bad code -- https://master.php.net/note/delete/96638/bad+code Del: spam -- https://master.php.net/note/delete/96638/spam Del: non-english -- https://master.php.net/note/delete/96638/non-english Del: in docs -- https://master.php.net/note/delete/96638/in+docs Del: other reasons-- https://master.php.net/note/delete/96638 Reject -- https://master.php.net/note/reject/96638 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166830) next »