Complete PHP Filesystem Reference
The file_put_contents() writes a string to a file.
This function follows these rules when accessing a file:
This function returns the number of character written into the file on success, or FALSE on failure.
| Parameter | Description |
|---|---|
| file | Required. Specifies the file to write to. If the file does not exist, this function will create one |
| data | Required. The data to write to the file. Can be a string, an array or a data stream |
| mode | Optional. Specifies how to open/write to the file. Possible
values:
|
| context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream. |
Note: Use FILE_APPEND to avoid deleting the existing content of the file.
The output of the code above will be:
Complete PHP Filesystem Reference
| WEB HOSTING |
|---|
| Best Web Hosting |
| PHP MySQL Hosting |
| Best Hosting Coupons |
| UK Reseller Hosting |
| Cloud Hosting |
| Top Web Hosting |
| $3.98 Unlimited Hosting |
| Premium Website Design |
| WEB BUILDING |
|---|
| Download XML Editor |
| FREE Website BUILDER |
| Best Website Templates Top CSS Templates |
| CREATE HTML Websites |
| EASY WEBSITE BUILDER |
| W3SCHOOLS EXAMS |
|---|
|
Get Certified in: HTML, CSS, JavaScript, XML, PHP, and ASP |
| W3SCHOOLS BOOKS |
|---|
|
New Books: HTML, CSS JavaScript, and Ajax |
| STATISTICS |
|---|
|
Browser Statistics Browser OS Browser Display |
| SHARE THIS PAGE |
|---|