Writing a String to a File in PHP


Use file_put_contents() to write a string to a file, creating the file if it doesn’t exist.

Source Code

$text = "Hello, world!";
file_put_contents("hello.txt", $text);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments