What for ?

The option "r" stans for "read".

If what William is doing is try to read a file, and then create one if it
doesn't exist, to me that doesn't make sense (sorry).
If the function would do that it would always return an EMPTY file in the
second situation, right ?

Now I ask "why in God's name I want to read an empty file?"

What makes (more) sense is to open a file to write on, with the possibility
to append if it exists or to create a new one if it doesn't.

What you suggest is "open, if it does not exist create".
You get a new (empty) file.
Then what ? Write ? That's what I wanted to say all along

Correct me if I am wrong


Luis

----- Original Message -----
From: "Svensson, B.A.T. (HKG)" <[EMAIL PROTECTED]>
To: "'Luis Moreira '" <[EMAIL PROTECTED]>; "''William Fisher ' '"
<[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, March 11, 2003 2:00 PM
Subject: RE: [PHP-WIN] Newbie attempting file open...


> Luis, read the code once again....
>
> -----Original Message-----
> From: Luis Moreira
> To: 'William Fisher '
> Cc: [EMAIL PROTECTED]
> Sent: 2003-03-11 12:03
> Subject: Re: [PHP-WIN] Newbie attempting file open...
>
> No need.
> It's the other way around, actually.
> The option that creates if the the file does not exist is "w". The "r"
> option only reads
>
> Luis
>
> ----- Original Message -----
> From: "Svensson, B.A.T. (HKG)" <[EMAIL PROTECTED]>
> To: "'William Fisher '" <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Tuesday, March 11, 2003 9:15 AM
> Subject: RE: [PHP-WIN] Newbie attempting file open...
>
>
> > You may want to try something like this:
> >
> > $fp = @fopen(<filename>,"r");
> >
> > if ($fp)
> > {
> >   print"An old file was opened!";
> >
> > } else  {
> >
> >  $fp = @fopen(<filename>,"w");
> >  fclose($fp);
> >  $fp = @fopen(<filename>,"r");
> >  print"New file was created!";
> > }
> >
> > -----Original Message-----
> > From: William Fisher
> > To: [EMAIL PROTECTED]
> > Sent: 2003-03-10 19:54
> > Subject: [PHP-WIN] Newbie attempting file open...
> >
> >
> > The Question:  It is my understanding that fopen() using the "r"
> option
> > will either open the indicated file for read only OR create one if it
> > doesn't exist. fopen() is giving me this error when trying to
> > create/open a file.
> >
> > Warning: fopen(c:/program files/apache group/apache/htdocs/test.txt)
> > [function.fopen]: failed to create stream: No such file or directory
> in
> > c:\program files\apache group\apache\htdocs\file_open.php on line 5
> >
> > The Code: What I've written...well...copied... is this:
> >
> > <?php
> >
> >  $DOCUMENT_ROOT = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
> >
> >  $fp = fopen("$DOCUMENT_ROOT/test.txt" , "r");
> >
> > ?>
> >
> >
> > The Guts: Windows ME, Apache 1.3.27, PHP 4.3.1.
> >
> > Why am I using ME? Call it compulsary. I buy the cheap gas, too. Any
> > ideas as to why this is happening? What's this whole file streaming
> > issue?
> >
> > Blessings,
> >
> > Zach Fisher....
> >
> >
> >
> > ---------------------------------
> > Do you Yahoo!?
> > Yahoo! Tax Center - forms, calculators, tips, and more
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to