Re: PHP Email....
| From: | David Robley | Date: | Fri, 13 Jun 2003 05:29:45 +0000 |
| Subject: | Re: PHP Email.... | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-151329@lists.php.net to get a copy of this message | ||
In article <20030612104307.20347.qmail@pb1.pair.com>,
brian.mcgarvie@anypurposeloans.co.uk says...
> > Working kind of :)
> >
> > Get one line from it....
>
> Kinda... I get it to return one line...
>
> The code:
>
> <?php
> define('STDIN',fopen("php://stdin","r"));
> $str = fgets(STDIN);
> mail("webmaster@anypurposeloans.co.uk","Test","Test
> Test...\n\nOriginal
> Email:\n\n$str");
> ?>
>
> Emails me:
>
> Test Test...
>
> Original Email:
>
> >From brian.mcgarvie@anypurposeloans.co.uk Thu Jun 12 11:41:39 2003
From the docs (fgets):
"Returns a string of up to length - 1 bytes read from the file pointed to
by fp. Reading ends when length - 1 bytes have been read, on a newline
(which is included in the return value), or on EOF (whichever comes
first). If no length is specified, the length defaults to 1k, or 1024
bytes."
So it's reading up to the first newline, as expected :-) Modify the
example from the manual to suit your needs:
$fd = fopen ("/tmp/inputfile.txt", "r");
while (!feof ($fd)) {
$buffer = fgets($fd, 4096);
echo $buffer;
}
fclose ($fd);
Cheers
--
Quod subigo farinam