I thought this would be fairly easy, but, I can't figure out how to load the
contents of a file into a variable so I can output it later.
The file to be loaded is in my include_path on the server and does contain
some HTML.
file_get_contents() is exactly what I need, but, it only works on a CVS
ðÒÉ×ÅÔ!
Monty wrote:
But it returns nothing. If I use readfile() the file contents is displayed,
but, what I really want to do is store it in a string variable, not output
it directly. How can I do this?
Look 4 implode() in the function list
ÐÏËÁ
áÌØÂÅÒÔÏ
ëÉÅ×
Look 4 implode() in the function list
Implode isn't really what I need, I just want to load an entire file into a
single string variable.
However, I figured out the problem shortly after posting that first message
(of course). Because the file being opened is in the include_path, it seems
Hi Monty,
I've been trying to do the same thing with no success. Would you be so kind
as to show me how you finally did it? I'm not too clear what you meant by:
So, if I replace the filesize($filename) command with a hard-coded number,
it works.
Tia,
Andre
On Thursday 18 July 2002 04:28 pm,
On Thu, Jul 18, 2002 at 04:28:57PM -0400, Monty wrote:
Look 4 implode() in the function list
Implode isn't really what I need, I just want to load an entire file into a
single string variable.
Yes, it IS what you need. Plus, to work around your other problems
mentioned in later posts...
In 4.3 you would use file_get_contents()
In prior versions I would suggest:
$fp = fopen('filename','r');
$string = fread($fp, filesize('filename'));
fclose($fp);
The implode(file()) stuff is very memory-inefficient.
-Rasmus
On Thu, 18 Jul 2002, Analysis Solutions wrote:
On Thu, Jul 18,
: [PHP] Loading a File into Variable - How??
Hi Monty,
I've been trying to do the same thing with no success. Would you be so kind
as to show me how you finally did it? I'm not too clear what you meant by:
So, if I replace the filesize($filename) command with a hard-coded number,
it works
into the fread().
From: [EMAIL PROTECTED] (Rasmus Lerdorf)
Newsgroups: php.general
Date: Thu, 18 Jul 2002 15:14:13 -0700 (PDT)
To: Analysis Solutions [EMAIL PROTECTED]
Cc: PHP List [EMAIL PROTECTED]
Subject: Re: [PHP] Loading a File into Variable - How??
In 4.3 you would use file_get_contents
8 matches
Mail list logo