PHP: Introduction. CS7025: Network Technologies and Server Side Programming Lecturer: Saturnino Luz

Similar documents
Short notes on webpage programming languages

Real SQL Programming 1

Web Pages. Static Web Pages SHTML

WIRIS quizzes web services Getting started with PHP and Java

Web. Services. Web Technologies. Today. Web. Technologies. Internet WWW. Protocols TCP/IP HTTP. Apache. Next Time. Lecture # Apache.

Government Girls Polytechnic, Bilaspur

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

INFORMATION BROCHURE Certificate Course in Web Design Using PHP/MySQL

Course Number: IAC-SOFT-WDAD Web Design and Application Development

CSCI110: Examination information.

Java Application Developer Certificate Program Competencies

Chapter 1 Programming Languages for Web Applications

SUBJECT CODE : 4074 PERIODS/WEEK : 4 PERIODS/ SEMESTER : 72 CREDIT : 4 TIME SCHEDULE UNIT TOPIC PERIODS 1. INTERNET FUNDAMENTALS & HTML Test 1

OIT 307/ OIT 218: Web Programming

WWW. World Wide Web Aka The Internet. dr. C. P. J. Koymans. Informatics Institute Universiteit van Amsterdam. November 30, 2007

Forms, CGI Objectives. HTML forms. Form example. Form example...

CTIS 256 Web Technologies II. Week # 1 Serkan GENÇ

Web Application Development

A Comparative Study of Web Development Technologies Using Open Source and Proprietary Software

Internet Technologies. World Wide Web (WWW) Proxy Server Network Address Translator (NAT)

Database System Concepts

HTML Basics(w3schools.com, 2013)

Outline. CIW Web Design Specialist. Course Content

LAMP [Linux. Apache. MySQL. PHP] Industrial Implementations Module Description

DYNAMIC TECHNOLOGIES ON THE WEB: EDUCATION ADMINISTRATION APPLICATIONS. Doug Martin, Ph.D. University of Cincinnati

GLEN RIDGE PUBLIC SCHOOLS MATHEMATICS MISSION STATEMENT AND GOALS

PHP Tutorial From beginner to master

Web design. FDC Workshop: WebPage Design. Agenda. All you wanted to know about designing your own personal webpage without daring ask about it!

Connecting with Computer Science, 2e. Chapter 5 The Internet

Xtreeme Search Engine Studio Help Xtreeme

Web Design Specialist

Business & Computing Examinations (BCE) LONDON (UK)

Web Development: Techniques for Handling Content. Shelley Slaey June 2, 2014

Internet Technologies_1. Doc. Ing. František Huňka, CSc.

COURSE CONTENT FOR WINTER TRAINING ON Web Development using PHP & MySql

Web Development using PHP (WD_PHP) Duration 1.5 months

Lecture 2. Internet: who talks with whom?

Web development... the server side (of the force)

ERIE COMMUNITY COLLEGE COURSE OUTLINE A. COURSE TITLE: CS WEB DEVELOPMENT AND PROGRAMMING FUNDAMENTALS

Web and e-business Technologies

Efficiency of Web Based SAX XML Distributed Processing

Equipment Room Database and Web-Based Inventory Management

CrownPeak Playbook CrownPeak Hosting with PHP

Using Database Metadata and its Semantics to Generate Automatic and Dynamic Web Entry Forms

LAMP Server A Brief Overview

ICT 6012: Web Programming

10CS73:Web Programming

Introduction to Server-Side Programming. Charles Liu

Credits: Some of the slides are based on material adapted from

PHP Skills and Techniques

How to start with 3DHOP

Module 13 Implementing Java EE Web Services with JAX-WS

TIME SCHEDULE OBJECTIVES

CSC309 Winter 2016 Lecture 3. Larry Zhang

12 File and Database Concepts 13 File and Database Concepts A many-to-many relationship means that one record in a particular record type can be relat

Server-Side Web Development JSP. Today. Web Servers. Static HTML Directives. Actions Comments Tag Libraries Implicit Objects. Apache.

VB.NET - WEB PROGRAMMING

Oracle Forms Services Secure Web.Show_Document() calls to Oracle Reports Server 6i

Web application development landscape: technologies and models

Lesson 7 - Website Administration

Further web design: HTML forms

How To Program In Javascript With Deitel And Deitle

OVERVIEW OF ASP. What is ASP. Why ASP

Accessing Data with ADOBE FLEX 4.6

ASP.NET: THE NEW PARADIGM FOR WEB APPLICATION DEVELOPMENT

Perl/CGI. CS 299 Web Programming and Design

Agenda. Summary of Previous Session. Application Servers G Session 3 - Main Theme Page-Based Application Servers (Part II)

CLIENT SERVER VERSUS DISTRIBUTED NETWORK APPLICATIONS IN HUMAN RESOURCE MANAGEMENT

VHDL Test Bench Tutorial

Web-Based Information Systems

HTML5. Turn this page to see Quick Guide of CTTC

Application Layer -1- Network Tools

Advanced Tornado TWENTYONE Advanced Tornado Accessing MySQL from Python LAB

Outline Definition of Webserver HTTP Static is no fun Software SSL. Webserver. in a nutshell. Sebastian Hollizeck. June, the 4 th 2013

Building Java Servlets with Oracle JDeveloper

ICADBS504A Integrate database with a website

Computer Networks. Lecture 7: Application layer: FTP and HTTP. Marcin Bieńkowski. Institute of Computer Science University of Wrocław

CSE 203 Web Programming 1. Prepared by: Asst. Prof. Dr. Maryam Eskandari

Fig (1) (a) Server-side scripting with PHP. (b) Client-side scripting with JavaScript.

PHP. Introduction. Significance. Discussion I. What Is PHP?

PHP MySQL vs. Unity. Introduction. The PHP side. The Unity side

4 Understanding. Web Applications IN THIS CHAPTER. 4.1 Understand Web page development. 4.2 Understand Microsoft ASP.NET Web application development

AJAX The Future of Web Development?

Chapter 21 Web Servers

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

ASSOCIATE IN ARTS DEGREE-60 UNITS

Performance Comparison of Database Access over the Internet - Java Servlets vs CGI. T. Andrew Yang Ralph F. Grove

Basic Internet programming Formalities. Hands-on tools for internet programming

Annex E - Capability Building Policy

«W3Schools Home Next Chapter» JavaScript is THE scripting language of the Web.

Modeling Web Applications Using Java And XML Related Technologies

Lecture 11 Web Application Security (part 1)

Novell Identity Manager

Rweb: Web-based Statistical Analysis

Facebook Twitter YouTube Google Plus Website

IE Class Web Design Curriculum

How to Run an Apache HTTP Server With a Protocol

ICAWEB502A Create dynamic web pages

A DIAGRAM APPROACH TO AUTOMATIC GENERATION OF JSP/SERVLET WEB APPLICATIONS

Transcription:

PHP: Introduction CS7025: Network Technologies and Server Side Programming http://www.scss.tcd.ie/~luzs/t/cs7025/ Lecturer: Saturnino Luz January 24, 2011 1 PHP: Introduction How does a browser request a page from the server? 1. A connection is established over the internet 2. The client requests HTML 3. The server returns HTML 4. The client requests Image 1 5. The server returns Image 1 6. The client requests Applet 7. The server returns Applet 8. The connection is closed. HTTP The request the client makes may be for a document that resides on the server. This would be a static request. But we are interested in dynamic requests. The document is put together on the fly by the server, and returned. The page may contain data that are extracted from a database. User preferences, Identification: A cookie may have been set which uniquely identifies the user When the server receives a request that includes this cookie it recognizes the user and can tailor the page to the users requirements. 1

Web Applications The early web was information driven Largely static Posting of research information But now it is largely service driven The browser provides an interface to the service Largely dynamic Highly interactive Combining server and client side programming Usability becomes a serious concern Dynamic pages Mostly use the Three Tier Architecture: Presentation tier >GET SALES TOTAL >GET SALES TOTAL 4 TOTAL SALES Client Logic tier Web Server GET LIST OF ALL SALES MADE LAST YEAR ADD ALL SALES TOGETHER Data tier QUERY SALE 1 SALE 2 SALE 3 SALE 4 Database Server Database Storage Server side programming Within a web server we might: Identify a client (with a cookie) Retrieve relevant data (from a database) Process it based on the client query Build an HTML page around the processed information Record client feedback and update the database So we will need a server-side scripting module as well as an HTTP server 2

CGI Java servlets PHP ASP ColdFusion CGI - Common Gateway Interface PHP A standard for running external programs from a WWW HTTP server. CGI specifies how to pass arguments to the executing programs. Also defines a set of environment variables. Typically the program will compose some HTML which is passed back to the browser. The HTTP server is usually configured to treat certain URL s in a special way - instead of treating it as a file to be returned it is a program which should be run, and the output of the program is returned. Each time the CGI program is launched it is started afresh CGI programs can be quite resource intensive PHP stands for PHP: Hypertext Pre-processor Has evolved from a bag of hacks to a complete language for building dynamic web sites. Cross platform (Unix (including Linux, OS X etc), Windows) Runs on the server. PHP instructions should never reach the browser (it wouldn t know what to do with them anyway). Mixed content - PHP programs usually embedded in (X)HTML documents How does it work? Server-side language PHP is inserted into XML pages Interpreted by PHP engine, running on web server (script checked for correctness and then executed). Surrounding XML fragments along with output of script passed back to browser. Web server configured to recognise when XML documents should be passed through PHP engine (usually by having the file names end in.php or something similar). Unlike CGI scripts the PHP scripts are embedded within documents in the servers and processed by a separate PHP engine. 3

PHP scripts A PHP script is embedded within an (X)HTML document, using special markers: <html> <body> The area of the circle is: $value = 3.14159 * 76; echo $value; </body> </html> The echo command prints out a value (we can also use print for this). Variables in PHP Variables are used to store data within our PHP scripts Unlike JavaScript we do not need to declare variables before we use them: using a new name automatically creates a new variable. Variable names have the same rules as JavaScript names except that all variable names must begin with the $ symbol. A number of variables are pre-defined in PHP scripts How PHP works 1. The browser requests a resource from the server 2. The request is received by the server 3. The server recognises that the request is for a PHP document (and not, say, a normal HTML document) 4. The server calls the PHP engine which processes the script and returns the HTML to the server process 5. The server returns the HTML document to the browser Our first PHP script <html> <body> echo "Hello world"; </body> </html> 4

A second program We have some pre-defined programs in a PHP program that is being executed by a web server. The variable names are a bit odd: echo $_SERVER[ HTTP_USER_AGENT ]; Variable types in PHP In PHP, as in JavaScript, there are several variable types available. String, e.g. $name = "Hercules"; Numeric Integer, e.g. $integer = -32; Numeric floating point, or Double, e.g. $double = 2.0; Boolean, e.g. $rainy = true; Array, in two flavours: Numeric, e.g. $country[0] = "Ireland"; Associative, e.g. $country["ie"] = "Ireland"; Object (more about this later on) Variable types in PHP Normally PHP will decide automatically what type a variable has, choosing from the available types. But if you really want to specify it, then you can use an operation called a cast. If you do this, then PHP will convert the value of the variable for you, according to the rules for type conversion it has built in. $stringvariable = "14.2 Words"; $numericvariable = (double)$stringvariable; After this conversion we can do arithmetic on the variable $numericvariable. PHP will often do the conversion automatically for us, but sometimes we will want to specify it manually. This is a useful facility when taking data out of HTML form elements. References Davis, M. and Phillips, J. (2007). Learning PHP and MySQL. O Reilly Media, Inc., 2nd edition. 5