PHP tutorials, html tutorial, photoshop tutorial, ajax tutorials,java tutorial, web design tips tutorials, css tutorial, visual basic tutorial, dreamweaver tutorial, php tutorial, html tutorials, c++ tutorial, javascript tutorial, windows tutorials, free flash tutorials, free photoshop source codes, sql tutorial
Web Development Tutorials, Programming Tutorials, PHP Script Index
Home | Forums | Downloads | Books | Submit Content | Links

Programming Articles

  PHP articles
  MySql articles
  Visual Basic.Net articles
  Java articles
  ASP articles
  ASP.Net articles
  Visual Basic articles
  CSS articles

Programming Tutorials

  PHP tutorials
  MySql tutorials
  Visual Basic.Net tutorials
  Java tutorials
  ASP tutorials
  ASP.Net tutorials
  Visual Basic tutorials
  HTML tutorials
  CSS tutorials

Programming Source Codes

  PHP scripts
  Visual Basic.Net scripts
  JavaScript scripts
  ASP scripts
  ASP.Net scripts
  Visual Basic scripts

Our Partners

  Free Resources
  Publisherbank
  Free Link Directory
  PHP Magazine
  Webmaster Passion
  Search Engine Bank
  Free Directory Site
  Free PHP Scripts
  Links Shopping Mart
  Variety Bazar
  Urdu Office Tutorials
  Evernew Scripts
  Evernew Scripts
  Evernew Directory
  Our Achievements
  Web templates
  Buy and Sell Templates
  Text Link Traders
  Directory Metro
  Gifts Choice
  Valentines Ecards
  Template Directory

Working with files in PHP

Date:2006-03-19

Opening a File
The fopen function is used to open a file. This function needs two parameters. First, we must supply it with the name of the file that we want it to open. Secondly, we must tell the function what we plan on doing with that file (i.e. read from the file, write information, etc).

<?php
$handlefile= fopen("filename.txt", 'w');
?>

The file may be opened in one of the following modes:

r Read only. The file pointer is placed at the beginning of the file.
r+ Reading and writing. The file pointer is placed at the beginning of the file.
w Write only. The file pointer is placed at the beginning of the file, and the file contents are erased. If the file does not exist, an attempt will be made to create it.
w+ Reading and writing. The file pointer is placed at the beginning of the file, and the file contents are erased. If the file does not exist, an attempt will be made to create it.
a Write only. The file pointer is placed at the end of the file. If the file does not exist, an attempt will be made to create it.
a+ Reading and writing. The file pointer is placed at the end of the file. If the file does not exist, an attempt will be made to create it.

Closing a File
The fclose() function is used to close a file.
fclose($f);

Read data from file

The fread() function is used to read data from a file.

Delete file

In PHP, you can delete any file using unlink() function. unlink() function has one parameter that is file name you want to delete. The syntax of unlink() function is below:

<?
unlink($filename);
?>


Desclaimer | Privacy Policy | Submit Content | Links | Link to Us | Sitemap |Contact Us
Copyright Programming Tutorials, Web Development Tutorials, Source codes © All Rights are Reserved.
Powered By Evernew Solutions

Credit Card Consolidation - Car Insurance - Loans - Arizona Pools