web 2.0

How to use PHP & Fwrite() Write Text File

How to use PHP & Fwrite() Write Text File Learn how to use the PHP to Write Text File on web server and using function Fwrite()

ShotDev Focus:
- PHP & Write Text File (Fwrite())

Example

php_write_text_file.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?
$strFileName = "shotdev/my.txt";
$objFopen = fopen($strFileName, 'w');
$strText1 = "I Love ShotDev.Com Line1\r\n";
fwrite($objFopen, $strText1);
$strText2 = "I Love ShotDev.Com Line2\r\n";
fwrite($objFopen, $strText2);
$strText3 = "I Love ShotDev.Com Line3\r\n";
fwrite($objFopen, $strText3);

echo "File write completed.";

fclose($objFopen);
?>
</body>
</html>

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_write_text_file.php

Screenshot

PHP Write Text File

PHP Write Text File
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.