开发者

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

开发者 https://www.devze.com 2023-02-20 23:46 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
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

精彩评论

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