1.2.1337. Use File Append¶
When appending data to a file, one may also use the file_put_contents() function with the FILE_APPEND
option.
Using file_put_contents() also keeps the file open as little as possible, unlike keeping the resource open in PHP, between usages.
<?php
// appends the text to the end of the end of the file
file_put_contents($file, $text, FILE_APPEND);
// appends the text to the end of the end of the file
$fp = fopen($file, 'a');
fwrite($fp, $text);
?>
1.2.1337.1. Connex PHP features¶
1.2.1337.1.1. Suggestions¶
Use file_put_contents()
1.2.1337.1.2. Specs¶
Short name |
Structures/UseFileAppend |
Rulesets |
|
Exakat since |
2.3.5 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |