Reply to Creating a new file (apologies to anybody on php-db who got this)

Your name:

Reply:


Posted by John Meyer on 12/28/05 01:05

On Tuesday 27 December 2005 4:07 pm, James Lumb wrote:
> Hi,
> Does anyway know whether there is a PHP function which creates a new file?
> i know there is fwrite, fopen etc but is there any way of creating a new
> file? Thanks,
> James
>

fopen() will create a new file if you open it for writing and it does not
exist, as per these modes:

'w'   Open for writing only; place the file pointer at the beginning of the
file and truncate the file to zero length. If the file does not exist,
attempt to create it.
  'w+'   Open for reading and writing; place the file pointer at the beginning
of the file and truncate the file to zero length. If the file does not exist,
attempt to create it.
  'a'   Open for writing only; place the file pointer at the end of the file.
If the file does not exist, attempt to create it.
  'a+'   Open for reading and writing; place the file pointer at the end of
the file. If the file does not exist, attempt to create it.
'x'   Create and open for writing only; place the file pointer at the
beginning of the file. If the file already exists, the fopen() call will fail
by returning FALSE and generating an error of level E_WARNING. If the file
does not exist, attempt to create it. This is equivalent to specifying
O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is
supported in PHP 4.3.2 and later, and only works for local files.
  'x+'   Create and open for reading and writing; place the file pointer at
the beginning of the file. If the file already exists, the fopen() call will
fail by returning FALSE and generating an error of level E_WARNING. If the
file does not exist, attempt to create it. This is equivalent to specifying
O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is
supported in PHP 4.3.2 and later, and only works for local files.
--
Dr. Joseph Dolan: Isn't there a children's book about an elephant named Babar?
Fletch: I don't know. I don't have any.
Dr. Joseph Dolan: No children?
Fletch: No, elephant books.

[Back to original 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

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