learning web development. 3(+1) tier architecture php script remote services web server (apache,...

14
Learning Web development

Post on 19-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

Learning Web development

Page 2: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

3(+1) Tier architecture

PHP script

Remote services

Web Server (Apache, IIS)

Browser(IE, FireFox,

Opera)

Desktop (PC or MAC)

Database

Database Server

SQL

Client application

HTTP

HTML

Web Service

tables

DHTML

SMS

vision

touch

voice

SMS system

Page 3: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

PHP Origins

Rasmus Lerdorf (born Greenland, ed Canada)

PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP Hypertext Processor’

Other key developers: Zeev Surashi and Andi Gutmans (Israel)

Open Source

PHP version 4.4.3 current at UWE Due to upgrade to PHP 5

Page 4: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

Scripting languages

• A scripting language is:– often evolved not designed– cross-platform since interpreter is easy to port– designed to support a specific task – PHP -> Web support– un-typed variables (but values are typed) – implicit variable declaration – implicit type conversion – stored only as script files– compiled on demand– may run on the server (PHP) or the client (Javascript)

• What design and development are involved in using a scripting language like PHP for development in place of a compiled language (Java in JSP, .NET)?

Page 5: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

PHP details

• Procedural language– Compare with Javascript which is event-driven

• C-like syntax - { } ;• Extensive Function Library• Good Web-server integration

– Script embedded in HTML– Easy access to form data and output of HTML pages

• Not fully object-oriented – Java is fully object oriented – all functions have to be

in a class– In PHP, classes are additional but quite simple to use

Page 6: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

PHP and HTML

• HTML-embedded– PHP scripts are essentially HTML pages with

the occasional section of PHP script.– PHP script is enclosed in the tag pair:

• <?php print date(“H:I”) ?>

Page 7: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

• Free format - white space is ignored • Statements are terminated by semi-colon ; • Statements grouped by { … } • Comments begin with // or a set of comments /* */ • Assignment is ‘=’: $a=6• Relational operators are ,< , > == ( not a single equal) • Control structures include if (cond) {..} else { }, while (cond) { .. } ,

for(sstartcond; increment; endcond) { } • Arrays are accessed with [ ] : $x[4] is the 5th element of the array

$x – indexes start at 0 • Associative Arrays (hash array in Perl, dictionary in Java) are

accessed in the same way: $y[“fred”] • Functions are called with the name followed by arguments in a fixed

order enclosed in ( ) : substr(“fred”,0,2) • Case sensitive - $fred is a different variable to $FRED

C-like language

Page 8: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

Function library

• Basic tasks– String Handling – Mathematics – random numbers, trig functions.. – Regular Expressions – Date and time handling – File Input and Output

• And more specific functions for-– Database interaction –

• MySQL, Oracle, Postgres, Sybase, MSSQL .. – Encryption – Text translation – Spell-checking – Image creation – XML

Page 9: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

String Handling

• String literals (constants) enclosed in double quotes “ ” or single quotes ‘ ’

• Within “”, variables are replaced by their value: – called variable interpolation. “My name is $name, I think”

• Within single quoted strings, interpolation doesn’t occur • Strings are concatenated (joined end to end) with the

dot operator “key”.”board” == “keyboard” • Standard functions exist: strlen(), substr() etc • Values of other types can be easily converted to and

from strings – numbers implicitly converted to strings in a string context.

• Regular expressions be used for complex pattern matching.

Page 10: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

Learning PHP

• Start with just the basics, installing a script to output an HTML page

• Understand how PHP supports interaction with the Browser or other clients

• Understand how PHP supports integration with databases – MySQL

Page 11: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

A multi-lingual approach

• Learning one language– You can learn any language for a book or the web , given time, a

tutor and exercises

• Problems– which language to choose– Web development requires multiple languages– Your job will require you to use some other language – Python,

V.Net

• Solution– Supplement the books with a multi-lingual approach to data

structures – Provide a patterns-based approach to facilitate transferable

learning

Page 12: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

Data structures and data types• In the beginning

– with only machine code, programmers had to work with single memory locations, and write their own code to treat these as an array, as a date, a list.

• As understanding of the needs of programmers has increased, the computing industry has provided support for complex data structures by providing:– Modern languages with new primitive datatypes and functions to support

them e.g. array, associative array, string..– Object-oriented languages with a Class extension mechanism which

enable new structures and functions to be packaged and imported into programs e.g. Image class in Java

– Commonly available tools to allow structures to be defined and manipulated e.g. Relational database for tables, Excel for spreadsheets, Word processors for text.

– Interfaces to these tools – an API (Application Programmer Interface) which allows the tool to be used from a program rather than directly from the desktop e.g. SQL for an RDBMS, web services..

Page 13: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

Approach

• Develop a online textbook of data structures through the year.

• Improve the material with input from you

• Start with the most common datatype (?)

Page 14: Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)

The String

• The online chapter• ../DataStructures/String

• The basics

• Regular Expressions

• The anagram application