Lecture 4 Term 2 Introduction to PHP 30/1/12. Server Side Scripting This is a web server technology in which a user's request is fulfilled by running.

Slides:



Advertisements
Similar presentations
IS 6116 Introduction – 10 Jan Lecturer Details Aonghus Sugrue Website: aonghussugrue.wordpress.com
Advertisements

PHP I.
Java Script Session1 INTRODUCTION.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
BY: ALBERTO CABEZAS 4/19/2010. INTRODUCTION: PHP is considered today as one of the most famous scripting languages. PHP is widely used as a general purpose.
IST 221 Internet Concepts and Applications Introduction to PHP.
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
WHAT IS PHP PHP is an HTML-embedded scripting language primarily used for dynamic Web applications.
PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in PHP stands for PHP: Hypertext Preprocessor (a recursive acronym).
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
Programming with php By: Seth Larson. A little bit about PHP  PHP stands for PHP:  Hypertext Preprocessor  PHP is a widely-used general-purpose server-side.
CP3024 Lecture 3 Server Side Facilities. Lecture contents  Server side includes  Common gateway interface (CGI)  PHP Hypertext Preprocessor (PHP) pages.
ITD 3194 Web Application Development Chapter 4: Web Programming Language.
Copyright © cs-tutorial.com. Introduction to Web Development In 1990 and 1991,Tim Berners-Lee created the World Wide Web at the European Laboratory for.
Languages in WEB Presented by: Jenisha Kshatriya BCM SS09.
PHP. Why should we learn web programming? No need write socket programming. - You can forget TCP/IP & OSI layers. - Web server handles socket tasks for.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
INTERNET APPLICATION DEVELOPMENT For More visit:
PHP TUTORIAL. HISTORY OF PHP  PHP as it's known today is actually the successor to a product named PHP/FI.  Created in 1994 by Rasmus Lerdorf, the very.
Nael Alian Introduction to PHP
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Introduction to PHP A user navigates in her browser to a page that ends with a.php extension The request is sent to a web server, which directs the request.
Open Source Software Unit – 3 Presented By Mr. R.Aravindhan.
Overview: 1. Discussion of the basic architecture of a web application. 2. Discussion of the relevance of using MySQL and PHP in a web application.
Introduction to CS520/CS596_026 Lecture Two Gordon Tian Fall 2015.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
PHP. What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Introduction to PHP Advanced Database System Lab no.1.
What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports.
CSE 154 LECTURE 5: INTRO TO PHP. URLs and web servers usually when you type a URL in your browser: your computer looks up the.
Introduction to PHP.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
CHAPTER 6 Introduction to PHP5 Part I อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
PHP Introduction PHP is a server-side scripting language.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
Chap 2 – Getting Started COMP YL Professor Mattos.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
1 PHP Intro PHP Introduction After this lecture, you should be able to: Know the fundamental concepts of Web Scripting Languages in general, PHP in particular.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
PHP stands for …….. “PHP Hypertext Pre-processor” and is a server-side scripting language like ASP. PHP scripts are executed on the server PHP supports.
PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used, free, and efficient alternative.
1 Server Side scripting PHP. 2 What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are.
Introduction to PHP. PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP.
PHP Basics and Syntax Lesson 3 ITBS2203 E-Commerce for IT.
PHP using MySQL Database for Web Development (part II)
Introduction to Dynamic Web Programming
PHP (PHP: Hypertext Preprocessor)
PHP / MySQL Introduction
PHP Introduction.
WEB PROGRAMMING JavaScript.
PHP.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
IntroductionToPHP Static vs. Dynamic websites
Introduction to PHP.
PHP an introduction.
Web Application Development Using PHP
Presentation transcript:

Lecture 4 Term 2 Introduction to PHP 30/1/12

Server Side Scripting This is a web server technology in which a user's request is fulfilled by running a script directly on the web server to generate dynamic HTML pages. The primary advantage to server-side scripting is the ability to highly customize the response based on the user's requirements, access rights, or queries into data stores. 2

Ecommerce Applications E-Commerce applications exist since the 1960s. Electronic Data Interchange (EDI) Electronic Funds Transfer (EFT) Termed Telecommunications Applications. 3

EDI “….A set of computerised forms that automate common business processes such as purchase orders, invoices, shipping notices and requests for proposal”. 4

Problems with EDI Special software needed Costly transaction and processing fees Firms with several linked partners operating on different VANs often required different software and network connections. 5

Web Based E-Business Internet Intranet Extranet 6

Technical Challenges Lack of systems security, reliability, standards and some communication protocol Development tools are still evolving and changing rapidly E.g. Difficult to integrate the Internet and EC software with some existing databases and applications 7

Static Web Applications All information served to the clients browser is static. In other words the content for the page A served to client 1 is exactly the same as the content for page A served to client 2 The web server does not dynamically generate any part of the site’s content but simply serves static HMTL pages loaded from the Web Server’s file systems and sends them to the requesting client 8

Serving an HTM L page 9

Dynamic Web-Applications Initially, Common Gateway Interface Programming was used (CGI) Server-side scripting allows us create dynamic and interactive web sites PHP allows us create dynamic web sites 10

Serving a PHP file 11 Here are some fun things to do: 1.Go shopping 2.Play soccer URL: funstuff.php 3. Receive Request, find file and read it 4. Execute PHP statements 5. Send back results 6. Return Results 2. Send Request for PHP file 1. User enters web address to PHP file 7. Receive and interpret HTML file WEB SERVER Internet – Connect to Web Browser

Introduction to PHP PHP is a powerful server-side scripting language for creating dynamic and interactive websites PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP PHP is perfectly suited for Web development and can be embedded directly into the HTML code 12

PHP The PHP syntax is very similar to Perl and C PHP is often used together with Apache (web server) on various operating systems It can also be used with Microsoft's IIS on Windows. 13

What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, Generic ODBC, etc.) PHP is an open source software (OSS) PHP is free to download and use 14

What is PHP? It is a server side scripting language designed for the web PHP is embedded into HTML and is executed each time the web page is visited PHP is interpreted by the web server and generates HTML code or other output for the user to see 15

More on PHP PHP is an open source product. You have access to the source code. You can use it, alter it and redistribute it without charge. PHP originally Personal Home Page, now stands for PHP hypertext preprocessor. 16

Advantages of PHP Performance Database Integration Built-in libraries Cost Portability Source Code 17

Development Environment Server-side scripting - You need three things to make this work. The PHP parser (CGI or server module), a webserver and a web browser. You need to run the webserver, with a connected PHP installation. You can access the PHP program output with a web browser, viewing the PHP page through the server. 18

Programming PHP A typical PHP file includes: HTML PHP tags PHP statements Whitespace Comments Note When you view the source of an PHP file on the client side you will not see the server side script, all you may view is the HTML generated. 19

PHP Tags Order Processed”;?> This is the default tag used for PHP development It follows the style of the SGML 20

Example 1 Example <?php echo "Hi, I'm a PHP script!"; ?> 21

Create a variable <?php $a=14; $b=19; $result= $a + $b; echo $result; ?> 22

PHP Statements <?php echo " Order Processed "; ?> The keyword echo prints the text Order Processed to the user’s browser. Note: The semicolon at the end of the statement is mandatory, failure to include the semicolon will results in generating a syntax error. 23

Whitespace Can improve code readability. The addition of white space does not affect the execution of your code. White space makes your PHP file bigger but makes the code more readable. 24

Comments Comments act as essential documentation for a programmer’s code Explains the purpose of the script Who wrote it Why they wrote it the way they did The PHP interpreter will ignore the comments but it is important comments are included for updating and maintenance purposes 25

Creating Comments Multilined Comment /* Author: Mary Brown Last Modified: 3/9/08 */ Single line Comments Order Processed ” ;?>// Start printing order 26

Variables Variables in PHP are represented by a dollar sign followed by the name of the variable The variable name is case-sensitive A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores 27

Declaring a Variable Using PHP <?php $var = "Bob"; $Var = "Joe"; echo "$var, $Var"; // outputs "Bob, Joe" $4site = 'not yet'; // invalid; starts with a number $_4site = 'not yet'; // valid; starts with an underscore ?> 28

Variable Types A variable type refers to the kind of data that is stored in it. PHP data types include: Integer Double String Array Object 29

Arithmetic Operators They are usually applied to integers or doubles if you apply an arithmetic operator to a string PHP will try and convert it to a number If the string contains e or E it will be converted to a double otherwise it will be converted to int 30

Arithmetic Operators OperatorNameExample +Addition$a + $b -Subtraction$a - $b *Multiplication$a * $b /Division$a / $b %Modulus$a % $b 31

String Concatenation/Operator Used to add two strings together. Syntax: <?php $qty1=12; echo $qty1. "Purchased "; ?> To avoid having to write multiple echo commands use the (.) 32

Example 2 <?php $a="ebusiness "; $b="is great"; $result=$a.$b; echo $result; ?> Output: ebusiness is great 33

Comparison Operators OperatorNameUse ==equals$a==$b ===identical$a===$b !=Not equal$a!=$b <>Not equal$a<>$b <Less than$a<$b >Greater than$a>$b <=Less than or equal to $a<=$b >=Greater than or equal to $a>=$b 34

Logical Operators OperatorNameUseResult !NOT!$b Returns true is b is false and vice versa &&AND$a && $b Returns true if both $a and $b are true otherwise false ||OR$a || $b Returns true if either $a or $b are true otherwise false andAND$a and $b Same as && with lower precedence orOR$a or $b Same as ||, but with lower precedence 35

Control Structures Are structures within a programming language that allow us to control the flow of execution through a program or script. The constructs that tell the programs to make decisions are known as conditional statements. 36

If Statements If statements may be used to make a decision. If the condition is true the following code block is executed. <?php if ($a > $b) echo "a is bigger than b"; ?> 37

Else Statements This allows to provide an alternative action when the condition of the if statement is false. <?php if ($a > $b) { echo "a is bigger than b"; } else { echo "a is NOT bigger than b"; } ?> 38

elseif Statements <?php if ($a > $b) { echo"a is bigger than b"; } elseif ($a == $b) { echo "a is equal to b"; } else { echo "a is smaller than b"; } ?> 39

Switch statements The switch statement is similar to a series of IF statements on the same expression. You may want to compare the same variable (or expression) with many different values, and execute a different piece of code depending on which value it equals to. 40

<?php switch ($a) { case 0: echo "a equals 0"; break; case 1: echo "a equals 1"; break; case 2: echo "a equals 2"; break; default: echo "a is not equal to 0, 1 or 2"; } ?> 41

Iteration:While loops It tells PHP to execute the nested statement(s) repeatedly, while the expression evaluates to true. The value of the expression is checked each time at the beginning of the loop, so even if this value changes during the execution of the nested statement(s), execution will not stop until the end of the iteration. If the while expression evaluates to false from the very beginning, the nested statement(s) won't even be run once. 42

While Loops <?php $i = 1; while ($i <= 10) { echo $i++; /* the printed value would be $i before the increment (post-increment) */ } ?> 43

For Loops for (expr1; expr2; expr3) statement The first expression (expr1) is evaluated once unconditionally at the beginning of the loop. In the beginning of each iteration, expr2 is evaluated. If it evaluates to true, the loop continues and the nested statement(s) are executed. If it evaluates to false, the execution of the loop ends. At the end of each iteration, expr3 is evaluated (executed). 44

For Loops <?php for ($i = 1; $i <= 10; $i++) { echo $i; } ?> 45

Do…While Loops do..while loops are very similar to while loops, except the truth expression is checked at the end of each iteration instead of in the beginning. The main difference from regular while loops is that the first iteration of a do..while loop is guaranteed to run. 46

Do..While Loops <?php $i = 0; do { echo $i; } while ($i > 0); ?> 47

Wamp Server Windows web development environment It allows you to create web applications with Apache, PHP and the MySQL database It also comes with PHPMyAdmin and SQLiteManager to easily manage your databases WampServer installs automatically and its usage is very intuitive You will be able to tune your server without even touching the setting files 48