H I O X INDIA
FREE PHP Topics
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Templates 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)
Español Français 中文 Deutsch Portuguese Japanese தமிழ்
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

PHP Topics
Introduction
Syntax
Data Types
Variables
Operators
Control Structures
Functions
Pre-defined Function
Calendar Functions
Date and Time
Array Functions
Array Functions List1
Array Functions List2
Math Functions
PHP Mysql Functions
File Handling
Error Handling
DB Size
PHP Mail
String Tokens
String Functions
String Functions List1
String Functions List2
Session Functions
Cookies Functions
Form Variables
Running PHP from JS
Array To JS
Array to PHP
Encryption
Common Header
Ask Your Doubts
More about PHP
Feedback





Creating a file using php


Topic

How to create a file in php?



Explanation

Step 1:
Creating a new file in php is done using the function fopen().

Example: fopen('filename','w');

To create a file using php
a) call the function fopen with two required arguments.
b) the first argument should be the file name. The new file will be created with the file name under the current(same) directory.
c) the second argument should be 'w' indicating it as write mode.


Creating a new file under different Directory:
To create a file in a different directory we have to pass the full file path as the argument for file name.

Example: fopen('./images/filename.txt','w');

This will create a file named filename.txt under the directory "images/"
It is important to note that the directory specified in the path should exist.




privacypolicy     licence     sitemap
© 2004-2010 HIOX INDIA