0% found this document useful (0 votes)
25 views10 pages

PHP Seminar: Submitted By, S. Yogalakshmi

This document summarizes topics to be discussed in a PHP seminar, including arrays, include/require statements, database functions, and file handling. It describes how include/require inserts one file into another, and the differences between the two. It also outlines various file handling functions for creating, reading, uploading, and editing files such as fopen(), fclose(), fread(), fgets(), fgetc(), feof(), fwrite(), and how to upload files using the $_FILES array.

Uploaded by

Yoga Lakshmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views10 pages

PHP Seminar: Submitted By, S. Yogalakshmi

This document summarizes topics to be discussed in a PHP seminar, including arrays, include/require statements, database functions, and file handling. It describes how include/require inserts one file into another, and the differences between the two. It also outlines various file handling functions for creating, reading, uploading, and editing files such as fopen(), fclose(), fread(), fgets(), fgetc(), feof(), fwrite(), and how to upload files using the $_FILES array.

Uploaded by

Yoga Lakshmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

PHP SEMINAR

Submitted By,
S.
Yogalakshmi

Topics to be discussed..
Arrays
Include and require statement
Database functions
File Handling

Include and Require


statement
Insert the content of one PHP file into
another PHP file
Syntax
include 'filename;
or
require 'filename';
Example
<?php include header.php';?>

The include and require


statements are identical, except
upon failure:
require will produce a fatal error
(E_COMPILE_ERROR) and stop the script
include will only produce a warning
(E_WARNING) and the script will
continue

File Handling
Manipulating Files
functions for creating, reading, uploading,
and editing files

readfile()
readfile() function reads a file and writes it to
the output buffer
open up a file and read its contents

fopen()
$myfile = fopen("webdictionary.txt", "r") or
die("Unable to open file!");

fclose()
The function is used to close an open file.

fread()
The fread() function reads from an open file.
first parameter contains the name of the file
second parameter specifies the maximum
number of bytes to read.

fgets()
read a single line from a file
Ex. $myfile = fopen("web.txt", "r") or die("Unable
to
open file!");
echo fgets($myfile);

fgetc()
function is used to read a single character from a file.

feof()
The feof() function checks if the "end-of-file" (EOF)
has been reached
useful for looping through data of unknown length.
Example,
$myfile = fopen("webdictionary.txt", "r") or die("Unable to
open file!");
// Output one line until end-of-file
while(!feof($myfile)) {
echo fgets($myfile) . "<br>";
}
fclose($myfile);

fwrite()
function is used to write to a file.
Ex.
$myfile = fopen("newfile.txt", "w") or
die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
fclose($myfile);

File Upload
upload files to the server
Rules to follow for the HTML form
above:
Make sure that the form uses
method="post"
The form aneeds the following attribute:
enctype="multipart/form-data". It
specifies which content-type to use
when submitting the form

upload script
is an associate double dimension array and
keeps all the information related to uploaded
file
$_FILES['file']['tmp_name']-the uploaded file in
the temporary directory on the web server.
$_FILES['file']['name'] -the actual name of the
uploaded file.
$_FILES['file']['size'] -the size in bytes of the
uploaded file.
$_FILES['file']['type'] -the MIME type of the
uploaded file.
$_FILES['file']['error'] -the error code
associated with this file upload.

You might also like