phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP File: Working Easy with File (Create and Write)

Tag: File, Create File, Write to File   Category:
post: 04 Jan 2008 read: 751


PHP File Tutorial: After learn read file, We will learn how to create a file. When we create a file, also write something to the file. We still use class.file to make our job more easy. Let's do it.

Create a file name "create.php" within www/test/file. Enter following codes:


 <?
 include "class.file.php";
 
 $f = "new.file.txt";
 $content = "hi... it's just test";
 
 $file = new file($f);
 
 if( $file->write($content) ){
 	echo "sucess";
 }else{
 	echo "fail";
 }
 ?>
It is realy simple, isn't?


Series this article:
PHP File: Working Easy with File (Read File)
PHP File: Working Easy with File (Create and Write)
PHP File: Working Easy with File (Delete File)
PHP File: Working Easy with File (Download)

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting