Created
July 8, 2019 09:19
-
-
Save SumonMSelim/a3c0da243ee5019e0a5db606f1050330 to your computer and use it in GitHub Desktop.
php append to file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$tag_to_add = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'; | |
$file = 'file.xml'; | |
// Using file_put_contents() | |
$myfile = file_put_contents($file, $tag_to_add.PHP_EOL , FILE_APPEND | LOCK_EX); | |
// Using fwrite() | |
$fstream = fopen($file, 'a'); | |
fwrite($fstream, '\n'. $tag_to_add); | |
fclose($fstream); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment