| ||
File Create
First a file has to exist! In this lesson you will learn how to create a file. PHP
- Creating Confusion In PHP, a file is created using a command that is also used to open files. This is a little confusing. The fopen function is used to open files. If fopen does not find the file specified (does not exist), it will create that file. PHP - How to Create a File The fopen function needs two information to operate correctly.
(i.e. read, write, append etc). PHP Code: $FileName
= "testFile.txt"; $FileHandle = fopen($FileName, 'w'); fclose($FileHandle); The file "testFile.txt" should be created in the same directory where this PHP code resides. When PHP saw that "testFile.txt" does not exists and fopen created that file. Let's look closely at the codes.
Note |