RSS
 

Posts Tagged ‘scratch pad’

PHP Tutorial (File Handling): Scratch Pad

09 Jan


Prerequisite

  1. Knowledge of basic PHP syntax.

In this tutorial you will learn about

  1. File Handling

Functions

We will be using 3 predefined functions for file handling

  1. fopen: To open a file
  2. file_get_content: To read a file
  3. fclose: To close a file

Little theory before we begin

Opening a file

Predefined function fopen() is used to open a file. It returns a variable which can be used for accessing the file. Returned variable is called as file handler.
Syntax:

$var = fopen("path to file", "mode");
 

mode: It controls how you want to access a file.
Note: It opens the file only if the logged-in user has permission to open it. If unable to open the file it returns false.
Read the rest of this entry »