Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Open a File for Writing
How To Open a File for Writing? - PHP Script Tips - Reading and Writing Files
✍: FYIcenter.com
If you want to open a new file and write date to the file, you can use the fopen($fileName, "w") function. It creates the specified file, and returns a file handle. The second argument "w" tells PHP to open the file for writing. Once the file is open, you can use other functions to write data to the file through this file handle. Here is a PHP script example on how to use fopen() for writing:
<?php
$file = fopen("/temp/todo.txt", "w");
fwrite($file,"Download PHP 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.
Note that you should use "\r\n" to terminate lines on Windows. On a Unix system, you should use "\n".
2007-04-22, 5041👍, 0💬
Popular Posts:
How To Create an Array in PL/SQL? - Oracle DBA FAQ - Introduction to PL/SQL If you want create an ar...
What is the difference between "printf(...)" and "sprintf(...)"? sprintf(...) writes data to the cha...
Can you explain project life cycle ? Figure :- 12.2 Life cycle of a project There are five stages of...
How To Return Top 5 Rows? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqueries If you want ...
What will be printed as the result of the operation below: main() { char *p1; char *p2; p1=(char *)m...