Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1

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

3 Basic Architecture of a Web Application Additional considerations in the architecture Client Server Operating System

4 TASKS OF THE WEB SERVER The Web server has what seems to be a fairly straightforward job. It sits there, running on top of your operating system, listening for requests that somebody on the Web might make, responding to those requests, and serving out the appropriate Web pages. In reality, it is a bit more complicated than that, and because of the 24/7 nature of the Web, the stability of the Web server is a major issue. There are many Web servers out there, but two dominate the market. These are Apache and Microsoft’s Internet Information Server (IIS).

5 TASKS OF THE MIDDLEWARE The middleware work closely with the Web server to interpret the requests made from the World Wide Web, process these requests, interact with other programs on the server to fulfill the requests, and then indicate to the Web server exactly what to serve to the client’s browser.

6 RELATIONAL DATABASES Relational database management systems (RDBMSes) provide a great way to store and access complex information. They have been around for quite a while. In fact, they predate the Web, Linux, and Windows, so it should be no surprise that there are many RDBMSes to choose from. All the major databases make use of the Structured Query Language (SQL).

7 Tools to check before running PHP application (with MySQL). In PHP you should have the following software: 1. PHP code editor (IDE). 2. PHP compiler/interpreter. 3. Web Server While in MySQL: 1. Driver 2. Server 3. The MySQL Database Manager

8 The PHP script Now’s the time to move to the text editor. In the course of configuring your Web server, you need to let it know which files should be handed off to PHP so the engine can interpret the page. Most often, these files have a.php extension, though it is possible to have PHP interpret anything, including.html files. These scripts live inside the folder designated to hold Web pages. For Apache, this is usually /htdocs.

9 BASIC SYNTAX One neat thing about PHP is that it lets you move between straight HTML and commands that are part of the PHP programming language. It works like this: The sections of your script between the opening tag ( ) are interpreted by the PHP engine, and portions not within these tags are treated as plain HTML. Check out the following PHP page.

10 11 and $var <?php echo “Hi”; ?> mom. Code Overview

11 Connecting to the Database (PHP to MySQL) <?php mysql_connect(“localhost”,”nobody”,”ydobon”) or die(“ could not connect toMySQL \n”); mysql_select_db(“guestbook”) or die(“ could not select database ‘guestbook’ \n”); ?>

12 Working with PHP Getting Started with PHP – variables Data types Operators Control Structure If statement else statement elseif statement Switch statement Iteration while loop for loop do.. While loops PHP’s built-in function Writing organized and readable code

13 Assigning Simple Variables Within a Script $a = “this is a string”; //this is a string $b = 4; //this is an integer $c = 4.837; //this is a floating-point number $d = “2”; //this is another string Typing is flexible, and PHP is pretty smart about handling changes in types. Fore example, given the code you just saw, the following would evaluate as you’d probably hope: $e = $b + $d; echo $e;answer: 6

14 Another example: $a = 2; $b = “2 little piggies”; $c = $a + $b;answer: $c=4 $f = 2; //$f is an integer $g = 1.444; // $g is a double (floating-point) type $f = $f + $g; //$f is now a double typeanswer: 3.444

15 PHP will also do type conversions when comparing two variables. This is a good thing, because the most common values for a script, entries submitted from an HTML form, always come in as strings. Here’s an example: $a = ‘1.3’; if ($a == 1.3) { echo “‘$a’ is 1.3\n”; } else { echo “‘$a’ is not 1.3\n”; } answer: ‘1.3’ is 1.3

16 If you need to make a strict comparison, where the types as well as the values must match, you can use a triple equal sign (===) operator (or its inverse, !==). This most commonly arises when you need to distinguish between 0, NULL, FALSE, and an empty string, since in a normal comparison these will all be treated as equal. The following code demonstrates: $a = 0; if ($a === 0) { echo “‘$a’ is 0\n”; } else { echo “‘$a’ is not 0\n”; } if ($a === FALSE) { echo “‘$a’ is FALSE\n”; } else { echo “‘$a’ is not FALSE\n”; } The result: ‘0’ is 0 ‘0’ is not FALSE

17 Delimiting strings $my_name = “Jay”; $phrase = “Hello, my name is $my_name”; echo $phrase;

18 PHP TAG STYLES SHORT STYLE XML STYLE SCRIPT STYLE … ASP STYLE

19 PHP’s data type PHP supports the following data types: 1. Integer – wholes numbers 2. Double – real numbers 3. String – string characters 4. Array – use for multiple storage of values 5. Object – use to store instances of classes

20 PHP’s arithmetic operators

21 PHP’s string operator

22 PHP’s combined arithmetic operations

23 PHP’s comparison operators

24 PHP’s logical operators

25 Control Structure if else

26 Continued… elseif

27 switch case

28 ITERATION while loop

29 for loop for example

30 do..while loop example


Download ppt "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."

Similar presentations


Ads by Google