You are here: Re: PHP Function ? « All PHP « IT news, forums, messages
Re: PHP Function ?

Posted by Fred Atkinson on 07/12/05 16:26

On Tue, 12 Jul 2005 10:13:02 +0200, "Hilarion"
<hilarion@SPAM.op.SMIECI.pl> wrote:

>>><?php
>>>/*
>>> * for a small file
>>> */
>>>$linecount = count(file('file.txt'));
>>>echo $linecount;
>>>
>>>/*
>>> * for a big file (if you don't want to read the whole file into memory)
>>> */
>>>$linecount = 0;
>>>$handle = fopen("file.txt", "r");
>>>while (fgets($handle, 4096))
>>>{
>>> ++$linecount
>>>}
>>>fclose($handle);
>>>echo $linecount;
>>>?>
>>
>> I tried the above and I put the path to the log file in lines
>> 5 and 12. I get the following error message when I pull it up:
>>
>> Parse error: syntax error, unexpected '}' in
>> c:\www\mishmash.org\public_html\test\index.php on line 16
>>
>> I tried putting a ; after the } on line 16, but it yielded the
>> same error message.
>
>Put it _before_ the "}".
>
>
>Hilarion

That got it. There were currently 12 records in the file I
was looking at. It returned 1212. So, I deleted:

/*
* for a small file
*/
$linecount = count(file('file.txt'));
echo $linecount;

Now it returns 12.

Thanks,


Fred

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация