[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    Re: [PHP3] Read a file to *one* variable?
From:       Boaz Yahav <berber () netvision ! net ! il>
Date:       1998-05-30 8:31:27
[Download RAW message or body]

FYI, this example was in the examples page : 

Title:how can I read the entire contents of a file into a string?
Submited by: Suraski Zeev (bourbon@netvision.net.il)
Submited on May 29th 1998 at 13:35:53


//(Requires  the  latest  CVS  for  fread()): 

 function  file_to_string($filename) 
 { 
   if  ($file  =  fopen($filename, "r"))  { 
          $contents  = fread($file,filesize($filename)); 
          fclose($file); 
          return  $contents; 
   }  else  {  /*  file  doesn't  exist  */ 
            return  ""; 
   } 
 } 
 ?>


    Regards.

       Boaz Yahav
       Web Development Team

-------------------------------------------------------------
E-Mail:  berber@Netvision.net.il              Tel: 04-8560600

Home Page: http://www.NetVision.net.il        Fax: 04-8550345

TeleSales:           04-8560560      sales@netvision.net.il
WAN Support:         04-8560550      wan@netvision.net.il
Dial-up Support:     04-8560570      support@netvision.net.il
Administration:      04-8560660      admin@netvision.net.il

                  NetVision Ltd.
The No.1 Israeli Internet & Intranet Services Provider


On 29 May 1998, Lars Torben Wilson wrote:

> Date: 29 May 1998 19:05:55 -0700
> From: Lars Torben Wilson <torben@coastnet.com>
> To: bourbon@bourbon.netvision.net.il
> Cc: Colin Viebrock <cmv@privateworld.com>, php3@lists.php.net
> Subject: Re: [PHP3] Read a file to *one* variable?
> 
> Zeev Suraski <bourbon@netvision.net.il> writes:
> 
> > A more efficient way to do it would be something like
> > $fd = fopen($filename);
> > $contents = fread($fd,filesize($filename));
> > fclose($fd);
> 
> So it is. Missed that when it was added--it's documented in the 
> cvs tree now.
> 
> 
> Thanks,
> 
> Torben
> 
> --
> PHP 3 Mailing List   http://www.php.net/
> To unsubscribe send an empty message to php3-unsubscribe@lists.php.net
> To subscribe to the digest list:  php3-digest-subscribe@lists.php.net
> For help: php3-help@lists.php.net  Archive: http://www.tryc.on.ca/php3.html
> 
> 


--
PHP 3 Mailing List   http://www.php.net/
To unsubscribe send an empty message to php3-unsubscribe@lists.php.net
To subscribe to the digest list:  php3-digest-subscribe@lists.php.net
For help: php3-help@lists.php.net  Archive: http://www.tryc.on.ca/php3.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic