A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the File Input Output in Php page! Here, you'll find the source code for this program as well as a description of how the program works.
<?php
function write_file($file_name)
{
$file = @fopen($file_name, "w");
if ($file === false) {
echo "Cannot open file \"", $file_name, "\" for writing.\n";
return false;
}
fwrite($file, "Hello World.\n");
fwrite($file, "Testing one...\n");
fwrite($file, "two...\n");
fwrite($file, "three!\n");
fflush($file);
fclose($file);
return true;
}
function read_file($file_name)
{
$file = @fopen($file_name, "r");
if ($file === false) {
echo "Cannot open file \"", $file_name, "\" for reading.\n";
return;
}
while (!feof($file)) {
echo fgets($file);
}
fclose($file);
}
$file_name = "output.txt";
if (write_file($file_name)) {
read_file($file_name);
}
File Input Output in Php was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.