开发者

How to write to files using the fwrite() function in php [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

My value in array and i want to prient each value in in seprat开发者_如何学运维es line


$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Bobby Bopper\n";
fwrite($fh, $stringData);
$stringData = "Tracy Tanner\n";
fwrite($fh, $stringData);
fclose($fh);

http://www.tizag.com/phpT/filewrite.php

Please google next time...


Use "\n" instead of '\n'. Single quotes interpret less special characters than double quotes.


On Windows, use "\r\n" instead of "\n", because line endings in Windows are different than in Unix.


If you have the luxury of php5:

file_put_contents($filename, "My name is Alok Ranjan Dubey.\n");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜