Tools, FAQ, Tutorials:
Writing a String to a File with a File Handle in PHP
How To Write a String to a File with a File Handle in PHP?
✍: FYIcenter.com
If you have a file handle linked to a file opened for writing, and you want to write a string to the file, you can use the fwrite() function. It will write the string to the file where the file pointer is located, and moves the file pointer to the end of the string. Here is a PHP script example on how to use fwrite():
<?php
$file = fopen("/temp/todo.txt", "w");
fwrite($file,"Download PHP scripts at dev.fyicenter.com.\r\n");
fwrite($file,"Download Perl scripts at dev.fyicenter.com.\r\n");
fclose($file);
?>
This script will write the following to the file:
Download PHP scripts at dev.fyicenter.com. Download Perl scripts at dev.fyicenter.com.
⇒ Writing a String to a File without a File Handle in PHP
⇐ Reading a File in Binary Mode in PHP
2016-11-27, ∼2951🔥, 0💬
Popular Posts:
What Is Azure API Management Service? Azure API Management as a turnkey solution for publishing APIs...
How to add a new operation to an API on the Publisher Dashboard of an Azure API Management Service? ...
Why am I getting this "Docker failed to initialize" error? After installing the latest version of Do...
How to run CMD Commands in Dockerfile to change Windows Docker images? When building a new Windows i...
How To Access a Specific Character in a String? Any character in a string can be accessed by a speci...