Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Programming with PHP (1). -Computer programming (often shortened to programming or coding) is the process of writing, testing, debugging/troubleshooting,

Similar presentations


Presentation on theme: "Web Programming with PHP (1). -Computer programming (often shortened to programming or coding) is the process of writing, testing, debugging/troubleshooting,"— Presentation transcript:

1 Web Programming with PHP (1)

2 -Computer programming (often shortened to programming or coding) is the process of writing, testing, debugging/troubleshooting, and maintaining the source code of computer programs. This source code is written in a programming language. The code may be a modification of an existing source or something completely new. The purpose of programming is to create a program that exhibits a certain desired behaviour (customization). The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic. (Wikipedia)Wikipedia -Structured programming can be seen as a subset or sub-discipline of procedural programming, one of the major programming paradigms. It is most famous for removing or reducing reliance on the GOTO statement. -At a low level, structured programs are often composed of simple, hierarchical program flow structures. These are sequence, selection, and repetition (iteration) Pre-amble (1) What is programming?

3 - an example of a structuring technique or methodology is Jackson Structured Programming (JSP) developed in the 1970’s by Michael Jackson -based on correspondences between data stream structure and program structure, JSP structures programs and data in terms of sequences, iterations and selections -an example of a JSP diagram: Pre-amble (2) Jackson Structured Programming

4 Pre-amble (3) Programming paradigms -a programming paradigm is a fundamental style of computer programming. (Compare with a methodology, which is a style of solving specific software engineering problems). Paradigms differ in the concepts and abstractions used to represent the elements of a program (such as objects, functions, variables, constraints, etc.) and the steps that compose a computation (assignation, evaluation, continuations, data flows, etc.). -paradigms include - procedural programming, functional programming, object-oriented programming, event-driven programming, process-oriented programming, logic-oriented programming etc. -some languages (e.g. ruby, xslt) are oriented towards certain paradigms (oo, functional) and some languages (php) can support multiple paradigms (procedural, oo, functional) though it is usually thought of as a procedural language.

5 Pre-amble (4) Remembering the Web (1) 1993

6 Pre-amble (5) Remembering the Web (2) Basic web 1.0 architecture & communication

7 Pre-amble (6) stuff you (already) need to know basic html recognize and write basic xhtml - the common tags? - common form layout and data-types? - well-formed? - doctype declaration? basic css recognize and write basic css - basic css syntax? - the notions of external/embedded/inline styles? - the basic idea behind the document object model (dom)? basic javascript recognize basic javascript syntax? - know in what situations and tasks javascript is a useful technology? Basic html, css & javascript

8 PHP Origins Originally created by Rasmus Lerdorf (born Greenland, educated in Canada) around 1995Rasmus Lerdorf PHP originally abbreviated as ‘Personal Home Pages’, now known as ‘PHP Hypertext Preprocessor’ Other key developers: Zeev Surashi and Andi Gutmans (Israel) responsible for PHP 3.0 - a complete re-write of the original PHP/F1 engine (1997) PHP is Open Source software First version PHP/FI released 1995 PHP 5.0 released July 2004 Current version is 5.3.0 PHP version 5.2.4 current at UWE PHP Version 6 due for release late 2009 / early 2010

9 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, Perl) or the client (Javascript) What are the potential differences in programming using an interpreted scripting language like PHP in place of a compiled language (e.g. Java in JSP,.NET)?

10 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 (compulsorily) 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

11 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: 23:18

12 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(startcond; 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

13 Function library (700+) 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

14 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.

15 http request/response cycle

16 3-tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC) Database Server SQL Client application HTTP HTML Web Service tables DHTML SMS vision touch voice SMS system

17 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 Understand how PHP supports integration with other applications – Web services

18 PHP Resources -hand out : -php home : http://www.php.nethttp://www.php.net -learning PHP : php @ w3 schoolsphp @ w3 schools -code and examples : php extension & application library (pear) : http://pear.php.net/ http://pear.php.net/ resource index : http://php.resourceindex.com/http://php.resourceindex.com/ weberdev : http://www.weberdev.com/ArticlesSearch/Category/Begi nner+Guides http://www.weberdev.com/ArticlesSearch/Category/Begi nner+Guides phpexample : http://phpexamples.me/http://phpexamples.me/


Download ppt "Web Programming with PHP (1). -Computer programming (often shortened to programming or coding) is the process of writing, testing, debugging/troubleshooting,"

Similar presentations


Ads by Google