Nothing Special   »   [go: up one dir, main page]

Servers or Clients

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 26

Introduction

The Internet is a worldwide collection of computer networks, cooperating with each other to exchange data using a common software standard. All of the machines on the Internet are either servers or clients. The machines that provide services to other machines are servers And the machines that are used to connect to those services are clients.

Introduction.

There are Web servers, e-mail servers, FTP servers and so on serving the needs of internet users all over the world. Client-Server Interaction

Request / Response Cycle..

Request / Response Cycle You enter http://server.com into your browsers address bar. Your browser looks up the IP address for server.com. Your browser issues a request for the home page at server.com. The request crosses the Internet and arrives at the server.com web server. The web server, having received the request looks for the web page on its hard disk. The web page is retrieved by the server and returned to the browser. Your browser displays the web page.

Request / Response Cycle contd

Request/Response cycle in More Detail...

You enter http://server.com into your browsers address bar. Your browser looks up the IP address for server.com. Your browser issues a request to that address for the web servers home page. The request crosses the Internet and arrives at the server.com web server. The web server, having received the request, fetches the home page from its hard disk. With the home page now in memory, the web server notices that it is a file incorporating PHP scripting and passes the page to the PHP interpreter. The PHP interpreter executes the PHP code.

in More Detail...

Some of the PHP contains MySQL statements, which the PHP interpreter now passes to the MySQL database engine. The MySQL database returns the results of the statements back to the PHP interpreter The PHP interpreter returns the results of the executed PHP code, along with the results from the MySQL database, to the web server. The web server returns the page to the requesting client, which displays it.

in More Detail...

Client-server architecture Web applications can be built using different tire architectures, which is the breaking down of an application into different logical places that are called Tiers. Tiers can exist on the same computer or on different machines.
1-Tier Architecture
single tier architecture is the equivalent of running an application on a personal computer(single user). User interface, business logic, and data storage are all located on the same machine. they are useless for designing web applications

Client-server architecture contd..

2-Tier Architecture
used to describe client/server systems where the client requests resources and the server responds directly to the request, using its own resources

Client-server architecture contd

3-tier architecture, There is an intermediary level, meaning the architecture is generally split up between: A client, i.e. the computer, which requests the resources, equipped with a user interface (usually a web browser) for presentation purposes The application server (also called middleware), whose task it is to provide the requested resources, but by calling on another server The data server, which provides the application server with the data it requires

Client-Side Scripting versus Server-Side Scripting When you create a dynamic html page the code that makes the changes to the web page must be run in one of two places. It can be client-side code executed by the user's web browser, or It can be server-side code executed by the server. There are advantages and disadvantages to using one over the other. Server side scripting The advantages of server-side scripting are:.
Because all of the server side code is executed before the HTML is sent to the browser, your code is hidden. Server-side code lets you easily access files and directories on the local machine

Client-Side Scripting versus Server-Side Scripting contd Server-side code is also browser independent. Because the HTML code returned by the server is simple HTML, you do not have to worry about the version of browser the client is using. The disadvantage to server-side scripting is that the server must use valuable resources to parse each page it sends out. This could slow down your web site. Server-side scripts include PHP, ASP, JSP, Perl and many others Client-side scripting The major advantage is: each web browser uses its own resources to execute the code found on the web page. This eases the load on the server. A client side script could be used to check the user's form input prior to submission to provide immediate notice of any errors by the user.

Client-Side Scripting versus Server-Side Scripting contd

The disadvantages are: You can not prevent the user from seeing your code you can not use client-side code to access local files, directories, or databases. It is browser dependent. For example: if you write a code with a JavaScript, To view your page JavaScript must be enabled in the web browser, and the browser being used must understand the version of JavaScript you have used. Client side scripts include JavaScript, JScript, VBScript and others

Client-Side Scripting versus Server-Side Scripting contd

By designing your web site to take advantage of the strengths and weaknesses of both client-side and server-side scripting, you can get maximum performance. To build well organized web site, you need
Hardware for the web server An operating system Web server software A database management system A programming or scripting language

PHP overview
PHP stands for "Hypertext Pre-processor The initials come from the earliest version of the program, which was called Personal Home Page Tools PHP is probably the most popular scripting language on the web. It is used to enhance web pages With PHP, you can do things like create username and password login pages, check details from a form, create forums, picture galleries, surveys, shopping carts and a whole lot more PHP is known as a server-sided language. That's because the PHP doesn't get executed on your computer, but on the computer you requested the page from.

PHP overview
Some of PHPs Strengths High performance
Using a single inexpensive server, you can serve millions of hits per day

Interfaces to many different database systems


In addition to MySQL,you can directly connect to PostgreSQL, mSQL, Oracle, dbm, FilePro

Built-in libraries for many common web tasks


You can generate GIF image, send email, work with cookies,and generate PDF documents

Low cost
PHP is free.

Ease of learning and use


If you already know C or a C-like language such as C++ or Java, you will be productive using PHP almost immediately

Strong object-oriented support Portability


Its platform independent You are free to modify or add something to the language

Availability of source code

What you need to get started with PHP

Before you can write and test your PHP scripts, there's one thing you'll need - a server! You can use software called Wampserver. This allows you to test your PHP scripts on your own computer It installs everything you need for windows operating systems.

Use Basic Syntax

Basic PHP Syntax A PHP script always starts with <?php and ends with ?>. A PHP script can be placed anywhere in the document. PHP files can contain text, HTML tags and scripts PHP files are returned to the browser as plain HTML PHP files have a file extension of .php or .php3

Use Basic Syntax contd


Here are all the four different styles of PHP tags.

XML style cant be disabled


<?php Phpstatements; ?>

Short style enable short_open_tag


<? Phpstatements; ?>

Script style
<script language=php> Phpstatements; </script> ASP style enable asp_tags <% Phpstatements; %>

Use Basic Syntax contd

PHP is an HTML-embedded scripting language. This means that you can intermingle PHP and HTML code within the same file. Now let see how we blend PHP and HTML together.
<html> <title>my php page</title> <body> <?php echo "hello world!"; ?> </body> </html>

Use Basic Syntax contd


Anything placed within these tags will be treated by the Web server as PHP (meaning the PHP interpreter will process the code). Any text outside of the PHP tags is immediately sent to the Web browser as regular HTML.
To make a basic PHP script:

1.

Create a new document in your text editor or Integrated Development Environment 2. Start a basic HTML document 3. Before the closing body tag, insert your PHP tags. <?php ?> 4. Save the file as first.php in in the proper directory of your Web server. 5. Run first.php in your Web browser
If you are running PHP on your own computer, youll need to go to something like http://localhost/first.php, http://127.0.0.1/first.php

6. If you dont see the desired results, start debugging.

Write Comments Creating executable PHP code is only a part of the programming process -its the most important part. A secondary but still crucial aspect to any programming endeavor involves documenting your code. PHP supports three comment types. The first uses the pound or number symbol (#): # This is a comment. The second uses two slashes: // This is also a comment. Both of these cause PHP to ignore everything that follows until the end of the line These two comments are for single lines only A third style allows comments to run over multiple lines: /* This is a longer comment that spans two lines. */

White spaces

Whitespace
Browsers ignore white spaces, carriage returns, and tabs in HTML; so does the PHP engine.

Send Data to the Web Browser


To create dynamic Web sites with PHP, you must know how to send data to the Web browser PHP has a number of built-in functions for this purpose, the most common being echo() and print(). ECHO(), echo(), eCHo(), and so forth will all work echo Hello, world!; echo Whats new?; You could use print() instead, if you prefer: print Hello, world!; print Whats new?; You can use either single or double quotation marks

Send Data to the Web Browser

Along with learning how to send data to the Web browser, you should also notice that in PHP all statements must end with a semicolon As you might discover,one of the complications with sending data to the Web involves printing single and double quotation marks. Either of the following will cause errors: echo She said, How are you?; echo Im just lucky.; There are two solutions to this problem.

Send Data to the Web Browser

First, use single quotation marks when printing a double quotation mark and vice versa: echo She said, How are you?; echo Im just ducky.; Or, you can escape the problematic character by preceding it with a backslash: echo She said, \How are you?\; print I\m just ducky.;

Utilizing variables

You might also like