PHP/File Directory/Text File Write — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 10:37, 26 мая 2010
How to add text to the file
<?php
$myfile = "./test.txt";
$openfile = fopen ($myfile,"a") or die ("Couldn"t open the file");
fwrite ($openfile,"Have a nice day! \n");
fclose ($openfile);
$openfile = fopen ($myfile,"r") or die ("Couldn"t open the file");
$file_size=filesize($myfile);
$file_contents = fread ($openfile,$file_size);
$msg ="$file_contents";
fclose ($openfile);
echo $msg;
?>
Write string to text file
<?php
$subscriberInfo = "g@wbex.ru";
$fh = fopen("./text.txt", "at");
fwrite($fh, $subscriberInfo);
fclose($fh);
?>