Вы находитесь на странице: 1из 19

A Project Report on

PHP

Submitted By:
Meghna Agarwal
B.Tech., 4th Yr., C.S.E.
Agenda
Introduction
Features of PHP
PHP Basics
PHP Forms & File Handling
Sessions & Cookies
PHP Database
Conclusion
Introduction
PHP: Hypertext Preprocessor

Originally created by Rasmus Lerdorf in 1995

Server-side scripting language

Supports many databases

Open source
Features Of PHP
High performance
Simplicity
Built-in libraries
Object Oriented
Portability
Open source
Interface to many different database system
How PHP Works?
PHP.ini File
Used to configure how PHP runs on our
computer.

When PHP is sent to the PHP interpreter, it


reads the php.ini file to determine what
settings to use.
PHP Basics
PHP Syntax:-
<?php…………………….
?>
PHP Variables:-
$var_name = value;
PHP Arrays:-
Numeric array - An array with a numeric index
Associative array - An array where each ID key is
associated with a value
Multidimensional array - An array containing one or more
arrays
PHP Forms
A form provides a medium of interface for
the client and the server to interact with each
other.
A form allow the user to actually input raw
data into the application.
PASSES DATA

USER ENTER DATA ARE SENTWEB SERVER PHP SCRIPT


(WEBBROWSERS) ENGINE

GIVE RESPONSE OR OUTPUT PROCESS DATA


Attributes Of Forms
Action:
specifies the Uniform Resource Locator(URL)
that will process the form data and send the
feedback.

Method:
specifies the way the information is to be sent.

 URL:
There are two common methods for passing data from
one script to another: GET and POST.
Methods
$_GET and $_POST: retrieve information
from forms.

The $_GET function: collect values from a


form sent with method="get".

The $_POST function: collect values from a


form sent with method="post".
File Handling in PHP
The fopen() function: open files in PHP

The fclose() function: close an open file

The fgets() function: read a single line from a


file

The fgetc() function: read a single character


from a file
PHP Cookies
A small file that the server embeds on the user's
computer.
Cookie has its own life cycle similar to session:

Intailize the cookie->


setcookie(cookiename,value,expiretime,path,domain,security)
Assign the value->
$_COOKIE[‘cookie name’];
Use the cookie->
$_COOKIE[‘cookie name’]=$varname;
Destroy the cookie->
unset($_COOKIE[‘cookie name’]);
PHP Sessions
A server variable which is used to keep the user
information on the server.It has its own life cycle.

$_SESSION variable: store and retrieve session


variable.

The session_start() function: start the session.

 session_destroy() function: destroy the session.


Database in PHP
PHP supports many databases (MySQL,
Informix, Oracle, Sybase, Solid,
PostgreSQL, Generic ODBC, etc.)

MySQL is commonly used.

Data in MySQL is stored in database


objects called tables
PHP MySQL Connect to a
Database
mysql_connect() function creates the connection

mysql_close() function closes the connection

create database statement create a database

create table statement is used to create a table in


MySQL.
SYNTAX
 mysql_connect(servername, username,password);
Servername : Specifies the server to connect to
Default value is "localhost:3306“.
Username : Specifies the username to log in with
Default value is the name of the user
that owns the server process.
Password : Specifies the password to log in with.
Conclusion
PHP is a server-side technology
Easy to learn and use
PHP is forgiving
PHP supports a large number of major protocols
PHP enhanced pages can contain a mixture of
HTML and PHP code.
PHP does not slow down the system which is
really important in order to publish you site
online.
Thank You

Вам также может понравиться