[PHP] Loading a File into Variable - How??

2002-07-18 Thread Monty
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

Re: [PHP] Loading a File into Variable - How??

2002-07-18 Thread Alberto Serra
ðÒÉ×ÅÔ! 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 ÐÏËÁ áÌØÂÅÒÔÏ ëÉÅ×

Re: [PHP] Loading a File into Variable - How??

2002-07-18 Thread Monty
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

Re: [PHP] Loading a File into Variable - How??

2002-07-18 Thread Andre Dubuc
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,

Re: [PHP] Loading a File into Variable - How??

2002-07-18 Thread Analysis Solutions
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...

Re: [PHP] Loading a File into Variable - How??

2002-07-18 Thread Rasmus Lerdorf
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,

Re: [PHP] Loading a File into Variable - How??

2002-07-18 Thread Monty
: [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

Re: [PHP] Loading a File into Variable - How??

2002-07-18 Thread Monty
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