NYCPHP Meetup

NYPHP.org

[nycphp-talk] Sorry, really stupid question...

Phil Powell soazine at erols.com
Sat Dec 28 15:32:21 EST 2002


"Have the file chmoded"...

You completely lost me.  How can I chmod a file I have not yet opened?

Phil
----- Original Message -----
From: "Analysis & Solutions" <danielc at analysisandsolutions.com>
To: "NYPHP Talk" <talk at nyphp.org>
Sent: Saturday, December 28, 2002 2:56 PM
Subject: Re: [nycphp-talk] Sorry, really stupid question...


> On Sat, Dec 28, 2002 at 02:26:29PM -0500, Phil Powell wrote:
>
> > $fileID = fopen("nicknames.txt", "a") or die("Could not open " . $path .
"/nicknames.txt");
> >    chmod("nicknames.txt", 0755);
> >    fputs($fileID, $nickname . "\
"); fflush($fileID); fclose($fileID);
>
> Let's rewrite this in more efficient, readable code...
>    $File = '/path/to/nicknames.txt';
>    $fileID = fopen($File, 'a') or die("Could not open $File");
>    fputs($fileID, "$nickname\
");
>
> Key changes...
>    * Have the file chmoded in the first place, not every time you open it
>      up, nor while you have it open already.
>    * Changed double quotes to single quotes in fopen statement.  Double
>      quotes only needed when strings are evaluated (have variables in
>      them).
>    * fflush() isn't needed at all.
>    * fclose() happens automatically when the script ends, so is
>      only helpful when you have a long script.
>
> --Dan
>
> --
>                PHP classes that make web design easier
>     SqlSolution.info  | LayoutSolution.info |  FormSolution.info
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>  4015 7th Ave #4AJ, Brooklyn NY    v: 718-854-0335   f: 718-854-0409
>
>
> --- Unsubscribe at http://nyphp.org/list/ ---
>
>




More information about the talk mailing list