Re: .DAT file with PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/8/06, Paul Novitski <paul@xxxxxxxxxxxxxxxxxxx> wrote:
>
> At 10:27 AM 3/8/2006, Rory Browne wrote:
> >$filename = "filename.txt";
> >$file_content = join("\n", array_reverse(file($filename)));
> >echo $file_content;
>
>
> Rory,
>
> I think you've got the logic right.
>
> Tangentially, however, I recommend that you break it out into
> separate statements and not throw multiple functions into the same
> statement -- it's hard to proofread, it's hard to pinpoint where
> errors occur, and it's next to impossible to insert echo statements
> to debug the process.  Also for ease of debugging & maintenance, I
> recommend indicating the type of each variable with a prefix
> (a=array, s=string, etc.):


Different strokes for different folks. Code presention is something I take
very seriously, but I don't consider using the return value of one function
as a parameter for another to be a bad thing.

Meaningful, or conventional variables are another thing I take seriously. If
I wanted to keep track of types I'd use C++ or Java. I don't have a problem
with something like:


         $sFilename = "filename.txt";
>          $aFile_content = file($sFilename);
>          $aFile_reverse = array_reverse($aFile_content);
>          $sDisplay_content = join("\n", $aFile_reverse);
>          echo $sDisplay_content;
>
> I don't think PHP will "care" whether it's broken out or not --
> internally it's having to create temporary variables on the fly to
> store incremental values -- but your future self and other folks
> reading your code will thank you for it.
>
> Regards,
> Paul
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux