Intro to PHP

Download Report

Transcript Intro to PHP

1
Intro to PHP
Introduction to server-side scripts
(It’s all good :D)
© TAFE NSW 2013
2
What is PHP?
 PHP is a programming language :D
 PHP originally began in Germany as an acronym for Personal Home Page
 PHP now stands for PHP Hypertext Pre-Processor
 PHP is a server-side script used to dynamically produce web pages
 Used in Web Applications
 A web application is an application that runs over the entire internet (or intranet). It
works like a normal application installed on your computer (although slower because
it’s communicating over the internet) except that the processing is performed by an
external server rather than on your local computer.
 Apps run on all different platforms & devices
 PHP works in conjunction with HTML, CSS, JavaScript and SQL (Structure Query
Language)
(C) TAFE NSW 2013
3
What is a PHP file, and what can PHP do?
 PHP files have the file extension:
.php
 PHP files can contain any or all of the following: Text, HTML, JavaScript & PHP
code
 PHP scripts are executed on the web server and plain HTML is returned back
to the web browser
 PHP can generate dynamic page content
 PHP can add, delete and modify data in a database
 PHP can restrict user access to pages
 PHP can collect form data, and encrypt data
 PHP can send and receive cookies (nom nom nom)
 PHP can create, open, read, write and close files on the server
© TAFE NSW 2013
4
Why PHP?
 PHP is free, widely used, open source, cross-platform, cross-server & efficient
 There are many server-side scripting technologies available, PHP has
several potential competitors:
Developer
Language
Platform
Cost?
Microsoft
Active Server
Pages (ASP)
C#
Visual Basic (VB)
Windows, .Net
Closed Source
($Monies$)
Python Software Python
Foundation
Windows, Linux/Unix, Mac
Open Source
OS X, and has been ported
to the Java and .NET virtual
machines
Rails Core Team
Windows, Linux/Unix, Mac
OS X
(C) TAFE NSW 2013
Ruby on Rails
Open Source
5
Plain old web communication
Web Browser & Web Server Interaction
 Fetching static web pages from the internet (otherwise known as surfing the
net), is in very simple terms a conversation over the internet between the
web browser on your computer, and the web server on another computer.
 The conversation (without server-side scripting) looks something like this:
(C) TAFE NSW 2013
6
How does PHP work?
Web Browser & Web Server Interaction
 SQL is supported by all databases, and used with many languages, like PHP
 The conversation with PHP & MySQL looks something like this:
(C) TAFE NSW 2013
7
References & Further Reading
 Sklar, D Learning PHP 5, O’Reilly Media Inc, December 2008, Figures 1.1 & 1.2
 Wikipedia Pages:
 http://www.w3schools.com/php/
(C) TAFE NSW 2013