_php Example of Web program working principle

Source: Internet
Author: User
Tags ftp file php language

1.Web Program Working principle

(1) The meaning of the word Web

Network: "Computer" computer network, net

WEB: Computer World Wide Web (worldwideweb), Internet (Internet)

Web programs, as the name suggests, are programs that work on the web.

(2) Operating principle of stand-alone program

A stand-alone machine, that is, a computer that is not connected to another computer, is not on the network. For example: Two stand-alone A, B, only on a with the program x, to get X on B to run the results, you must install the X on B, and then run. If class B computers are more numerous, they need to be installed and run individually. There is no direct communication and collaboration between them. As shown in Figure 1.

(3) Client/server program working principle

Connecting a single computer to a network, such as connecting A and B to a network, allows services to be provided between them, such as a providing services to B. Common services are file sharing, ftp file downloads, and so on. We refer to the computer that provides the (response) service as the server, and the computer that accepts (requests) the service is called the client or the workstation (workstations). The client/server program works as shown in Figure 2.

The roles of the server and client can be converted. A computer that can provide services to itself, at which point it is both a server and a client. For example, if computer A shares its own folder A and then finds a on the network, you can download a, that is, you have provided the service yourself, and you have requested and responded to the service yourself.

This kind of computer collaboration between client/server is called C/s mode, or C/s architecture.

The C/S program is divided into two parts: server-side and client-side, which are called server-side programs (or service programs) and client programs (or client programs). For the client program, each client is also installed separately, which is the same as the distribution of stand-alone programs, but also troublesome. However, once the client program is installed, you can interact with the server through a communication line, or through the server, to communicate with other clients. Typical examples are commonly used chat program QQ, as shown in Figure 3.

(4) Browser/server program working principle

If through the client's browser (Browser), to the server to send a request to receive the results of its response, then, we call such a collaborative approach to B/s mode, or b/s structure, its working principle as shown in Figure 4:

At this point, the client program is the browser, and the browser installation is completed with the installation of the operating system, do not require additional user installation. For them, the use of B/s programs (such as the Internet to read news, send and receive e-mail), you do not need to install a dedicated client program, directly in the browser to operate. This makes the B/s program maintenance very convenient, because do not have to manage the client program, as long as the maintenance of the server-side program can be.

(5) Composition of c/S and b/S servers

Server, is the machine that undertakes the service task. These service tasks are performed by a general specialized software. Generally, the server software with a certain service function and its machine, are collectively referred to as XX server (XX represents a specific service). The software can be concentrated in one machine (Figure 5), which can be called a centralized server, or in a single machine (Figure 6), which can be called a stand-alone server, and multiple stand-alone servers can form a server farm or matrix.

Following the service tasks, several common server software is shown in table 1.

Server-side scripting: programs written in a server-side programming language.

Server-side programming language: A programming language that runs only on the server side and is interpreted and executed by the server, such as the PHP language.

(6) b/S procedures for the work of the specific process (Figure 7)

(7) The specific process of PHP program work

The process is a collaborative process between Apache, PHP, and browsers:

Users through the browser to the server to request PHP files (such as in the Address bar input: http://localhost/index.php), Apache in the Server user document publishing directory to find the browser requested PHP file, if not found, then return the error message to the browser, otherwise, Submit it to the PHP interpreter to interpret the execution, PHP interpreter to the PHP file syntax analysis, if found syntax errors, the Apache return error message (in the browser can identify the code) to the browser, otherwise execute the PHP program (may contain the operation of the database MySQL), The results of the PHP program execution (represented by the browser-aware code) are returned to the browser by Apache, and the browser interprets and executes the returned results, and the results of the execution are displayed in the browser window.

If the file requested by the browser is not a PHP file, it is an HTML file or JavaScript file. The process simplifies: Apache locates the HTML file or JavaScript file requested by the browser in the user's document publishing directory on the server, and if it is not found, returns an error message to the browser, otherwise, returns it to the browser, and the browser interprets and executes the returned results. The results of the execution are displayed in the browser window.

2. Browser working process

(1) Web Client work process

Any application system must have an interface that provides user action, that is, the user interface. Browser work, from the entire B/s program, is the user and B/s program to deal with an interface (interface). Its mission is to:

A. Collecting data entered by users

B. Sending user data to the server

C. Response returned by the receiving server

D. Interpreting, executing these codes

Visible, the browser acts as a proxy (agent) role for the server in the user. This agent has the function of collecting messages, requesting responses, and interpreting the instructions that the server sends back.

(2) Web client code

Whether it's an interface that the organization uses to collect user data, or a result interface that interprets instructions from the server, is implemented with Web client code. Common Web client code has languages such as HTML language, JavaScript language, CSS, XML, and so on.

3.HTML Working principle

(1) Introduction to HTML

Html:hypertextmarkuplanguage, Hyper Text Markup language.

The late 1980s, the European Particle Physics Laboratory (cern:theeuropeanlabloratoryforparticlephysics) Timberners-lee, the father of the WWW, found that people's visual processing is based on the page. So he came to the conclusion that the electronic material should be presented in the form of a page. Taking this as the starting point, he uses hypertext as the central management method to organize the data on the network, and proposes the method of establishing access and browsing the Web page: The Hypertext Markup Language is established, the Hypertext Transfer Protocol (HTTP:HYPERTEXTTRANSPORTPROTOCOL) is designed, Used to get a hyperlink file; Use the Uniform Resource Locator (Url:uniformresourcelocator) to locate a network file, site, or server.

(2) HTML working principle

HTML is not a programming language in nature, but a markup language. The so-called mark, in some books also called tags, from the object-oriented point of view, is the browser object logo meaning. It controls how text, pictures, and other browsers ' child objects behave in the browser, and how to create a link between files. These tags are placed in text-formatted files. The biggest difference between programs is that they can be used to control the execution of an operating system or application and complete a job. Hypertext Markup Language documents should be done as much as possible, from a formal perspective, regardless of the effect on any browser on any operating system.

(3) Basic structure of HTML

A. version statement, i.e. preface (prologue)

B. Head

C. Subject (Body)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.