Creating and Deleting Files


If a file does not yet exist, you can create it with the touch() function. Given a string representing a file path, touch() attempts to create an empty file of that name. If the file already exists, its contents won't be disturbed, but the modification date will be updated to reflect the time at which the function executed.

touch("myfile.txt");


You can remove an existing file with the unlink() function. As did the touch() function, unlink() accepts a file path:

unlink("myfile.txt");


All functions that create, delete, read, write, and modify files on UNIX systems require the correct file or directory permissions to be set.




Sams Teach Yourself PHP, MySQL And Apache All in One
Sams Teach Yourself PHP, MySQL and Apache All in One (3rd Edition)
ISBN: 0672328739
EAN: 2147483647
Year: 2004
Pages: 327

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net