note 44415 added to function.file-get-contents
| From: | erik at phpcastle dot com | Date: | Thu, 05 Aug 2004 08:53:50 +0000 |
| Subject: | note 44415 added to function.file-get-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-73990@lists.php.net to get a copy of this message | ||
When you want to get the file content from a file do it before you use the fopen ([file],
'w+') function. Otherwise you will get an empty string.
So:
<?php
$fc = file_get_contents ('file.txt');
echo $fc;
//echoes e.g. "This is just a text file..."
?>
<?php
$fo = fopen ('file.txt','w+');
$fc = file_get_contents ('file.txt');
echo $fc;
//echoes e.g. ""
?>
Maybe handy becouse this is a tricky part of the scripting ;-)
----
Manual Page -- http://www.php.net/manual/en/function.file-get-contents.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44415
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44415&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44415&report=yes
Search -- http://master.php.net/manage/user-notes.php