Introduction
In this article I describe the PHP FileSystem functions file_put_contents, fileatime, filectime and filegroup. To learn some other FileSystem functions, go to:
- FileSystem Function in PHP: PART 1
- FileSystem Function in PHP: PART 2
- FileSystem Function in PHP: PART 3
- FileSystem Function in PHP: PART 4
- FileSystem Function in PHP: PART 5
PHP file_put_contents() Function
The PHP file_put_contents function is used to write strings into a file and it returns the number of bytes that were written to the file or false on failure.
Syntax
| file_put_contents(file,data,mode,context) |
Parameters in file_put_contents function
The parameters of the function are:
| Parameter | Description |
| file | It specifies the path of the file where to write the data. |
| data | It specifies the data to write to the file. |
| mode | It specifies how to open or write to the file and its possible values are:
|
| context | It specifies the context of the file handle. |
Example
<?php
echo file_put_contents("test.txt","Welcome in MCN Solution!");
?>
Output
PHP fileatime() Function
The PHP fileatime function gives the last access of time of the specified file, in other words it returns the time the file was last accessed or false on failure. The time is returned as a Unix timestamp.
Syntax
| fileatime(filename) |
Parameter in fileatime function
The parameter of the function is:
| Parameter | Description |
| filename | It specifies the file to check. |
Example
<?php
$time = time();
echo "current date and times is ".date("m/d/y H:i:s ", $time);


Join the conversation! Your thoughts help the community grow.