[nycphp-talk] Sorry, really stupid question...
Sterling Hughes
sterling at bumblebury.com
Sat Dec 28 15:50:51 EST 2002
> "Have the file chmoded"...
>
>You completely lost me. How can I chmod a file I have not yet opened?
>
You can chmod a file at anytime, whether it is open or not. at the command
line you use the chmod command.
In response to the various fclose() message:
fclose() is *never* necessary. not even in long scripts, short scripts
or medium sized scripts. PHP 4 is reference counted, meaning when
the file pointer variable is no longer referenced in the script it is
automatically cleaned up.
-Sterling
> 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