PDA

View Full Version : creating a file in php



keith
March 19th, 2002, 18:43
ok, i'm stupid. looked all over php.net.

i know how to open files, write to them, and delete them. but how would i check if a file exists, and if not create it?

say i need to write to keith.txt, a file that doesn't exist yet. well before i can write to it, it must be created. what would i have to enter for it to be created?

Dusty
March 19th, 2002, 18:46
Just start writing to it. As long as the script is allowed to write in the directory you want the file in, it'll automatically create it. To check if a file exists, use file_exists (http://www.php.net/manual/en/function.file-exists.php).

keith
March 19th, 2002, 19:08
haha, yeah, figured it out a few minutes after posting the message. like i said: stupid. thanks for the response though.