What Is Php File
PHP:What Is Php File :
1. Fopen() : this function is used to open files in php.
Fopen(string , string);
When the first string argument is name of the file and second string argument is mode of operation.
The mode operations can be either of the following.
r readonly . starts at the begining of the file.
r + read/write.
w write only . opens and clears the contents of file or creates a new file if it doesnot exist.
a append . opens and writes to the end of the file or creates a new file if it doesnot exist.
a+ read/append. Presents file content by writing to the end of the file.
x write only. Creates a new file returns FALSE and an error if file already exists.
x+ read/write. Creates a new file . returns false and an error if file already exists.
This function returns a resource of type stream on success and false on failure.
3. Fclose(file resource) :
This function is used to close and open file.
4. Feof(file resource):
This function checks if the “end-of-file”(EOF) has been reached. This function return a boolean value. If end-of-file is reached this function returns true otherwise false.
You cannot read from files opened in w,a and x mode.
5. Fgets(file resource):
This function is used to read a single line from a file.
6. Fgetc(file resource):
The function is used to read a single character from a file.
Program to create a file with name india.txt in your application folder.
//$fp = fopen("india.txt","x");
$fp = fopen("india.txt","w");
echo "file create!!!";
echo "file is not created!!!";
resource(3) of type (stream) file create!!!
Program to read the data from file line by line or character by character?
$fp =fopen("india.txt","r") or exit("unable to open file!!!");
//$str = fgets($fp);
$str = fgetc($fp);
php file, open php file, php file upload, what is php file, php file uploader, php file extension, php read file, php file write, php delete file, php open file, php file download, php upload file.,