PHP Learning Treasure-Chapter II

Source: Internet
Author: User
Tags php programming php programming language what php
The scripting language of the server-side web

This chapter highlights
• Learn about static Dynamic Web pages
• Client-side vs. servo-Scripting languages
• Servo-End scripting language introduction

This chapter focuses on the server-side scripting language itself, as well as its relationship to static HTML and general user-side technologies. At the end of this chapter, readers will have a clear idea of what PHP can do, what it can't do, and how it can communicate with the client in general.

Static HTML

The most basic form of Web page is to write purely static, plain text pages in HTML. The simple HTML page in Figure 2-1 is an example.

The scripting language of the server-side web

This chapter highlights
• Learn about static Dynamic Web pages
• Client-side vs. servo-Scripting languages
• Servo-End scripting language introduction

This chapter focuses on the server-side scripting language itself, as well as its relationship to static HTML and general user-side technologies. At the end of this chapter, readers will have a clear idea of what PHP can do, what it can't do, and how it can communicate with the client in general.

Static HTML

The most basic form of Web page is to write purely static, plain text pages in HTML. The simple HTML page in Figure 2-1 is an example.

Figure 2-1 Static HTML Web page specification

The following is the source code for figure 2-1:

As shown in 2-2, when a client computer makes an HTTP request to a page from the server via the Web or intrantet, the server simply passes in plain text not found in the file.


When the data is sent back to the client computer, the browser makes the best processing and presentation of the original code content, user preferences, display size, and other factors. The contents of the HTML file on the server are identical to the original code of the page on the client computer.

Your very ordinary static HTML has the following advantages:

Any browser will be able to display it.

Most devices have the ability to display it.

It executes quickly on every request and uses only the fewest resources.

HTML is easy to learn or automatically generated.

Small changes can be made quickly to individual pages.

Of course, static HTML also has an unfavorable side:

Difficult to control design and layout configuration.

cannot be expanded to a large number of pages.

Interactivity is not good enough.

It is not easy to include meaningful metadata on the page.

It is not easy to cope with the rapid changes in content or personalized information.

Not very attractive.


Because... Can only be considered an "amateur" level or an ideal firm application (this ideal is determined as a Web page written by some computer science experts who believe that all Web pages should comply with HTML3.1 specifications and must be readable by all devices).

Many other technologies have been developed to address these limitations, including client-side JavaScript, cascading Style Sheet (CSS), and Java applets, as well as the server-side scripting language of the server-side repository connection. The technologies under development include XML and XSL, both of which are part of a variety of other specifications (XHTML, XSLT, XPath, ice, and so on).

If you take the time to learn about the capabilities of these technologies and whether they can be added to your Web site, you will be less likely to get a headache later. For any web site task on hand, the basic question to ask yourself first is: which end of the operation (computation) is executed, the client or the server?

The "dynamic" culvert is intended to have a basic and repetitive difference between "static" and "Dynamic"web "Web pages, but" dynamic "can represent almost everything except plain HTML. It is used both to describe the user-side functions and to describe the functions of the server. On the client side, "dynamic" can be viewed as multimedia display, scrolling header row, auto-Updated page, or hidden elements ... such as On the server side, this term is generally used to refer to the content that is being transmitted in the air and in an interactive combination.

User-side technology

For normal HTML, the most common additions to the content are on the client side. This includes the following aspects: Format extensions such as CSS and Dynamic HTML, client scripting language, Java applets, and Flash. The way these technologies are supported is (mostly supported) built into web browsing. Table 2-1 lists their features, which are partially overlapping.

Table 2-1 Extension of user-side HTML

The example of the page shown in Figure 2-3 is based on the same content as Figure 2-1.


As seen from the source code, this example adds some stylesheet, user-side scripting, and some more complex HTML code.


Unfortunately, the best selling point for client-side technology is also the worst-case trait: they depend entirely on the browser. The functionality of each browser varies greatly, even if different versions of the same brand differ. Everyone can also choose to configure their own browsers in different ways, for example, some people will be banned from using JavaScript because of security concerns, so that they cannot browse websites that overuse JavaScript for navigational purposes. (If we have the function shown in the previous example)

Furthermore, many users have a differential effect on the browser's upgrade effort due to cost or lack of technical reasons. Web developers should be aware of device-based browsing, general, and global users. Without exception, mass-market-oriented websites are trying to reach the widest range of users, for example, Yahoo! And Amazon have been insisting on using stylesheets and JavaScript for more than three years after adopting these standards. Under the pressure of the World Wide Web, many websites stubbornly persist in using the font tags and bgcolor attributes, and their customers may be those who use AOL3.0 on older Macintosh machines that are on the 13 o'clock display. Ironically, even after five years of rapid development in the Web, developers can make an absolute guarantee to their customers that they will only see plain text-based HTML. (or even a subset of HTML that has been successfully tested over time)

Finally, the client technology cannot do any work that needs to be connected to the back-end server. JavaScript cannot immediately generate a customized drop-down list based on the user preferences stored in the database, and when changes are required in the list, the web Developer must make manual modifications to the page (server-side JavaScript, but not much at present) for this issue, The servo-side JavaScript language is the savior that can fill this gap.

In summary, all actions that deal with layout configuration or browser events occur on the client side. In general, the seemingly cool effects or things that depend on the mouse movement are on the client side. The faster you can see an event appearing, the more likely it is to be handled by the client, because fast means that you do not need to download from the server.

Attention:
Java applets, also known as "client-side Java (user-side Java), is less dependent on the browser than any other technology on the client side. As the name implies, they are complete small Java applications that pass through the Internet, but unlike applications written in other programming languages, the Java applets executes on the user-side of the operating system, called the JVM (Java Virtual Machine,java virtual Host) on the mediation software. The JVM can be seen as an operating system that exists on a real operating system. Most of the latest browsers will go into the JVM, and of course you can download one for yourself. This distinction in work makes it possible for applets to be limited by the relative weakness of the browser when the browser is in a special function.

Applets were considered insignificant in the early days, as they were initially used to implement simple motion books, such as icons that looked like Scotch tape, the title column that would scroll, the key knots, and so on. Fortunately, applets have changed and can be used for some very humane purposes, such as crossword puzzles, Hanoi simulations, wearable suits and ornaments, and virtual methods.


Servo-scripting language

Figure 2-4 is the server scripting Data flow.

The user-side scripting language is very attractive, the most eye-catching part of web development on the merits. The servo-terminal program is just the opposite, it is invisible to the user and hidden behind. The terminal scripting Program designers always work on the back-end Web server's data, while in front of his brother-in-law have art cell colleagues can be in front of the public to show their work.

The scripting language of the server Web is mainly to connect the W EB Web site to the backend server, such as the database, which allows two-way communication:


The scripting language of the server Web is mainly to connect the W EB Web site to the backend server, such as the database, which allows two-way communication:

Server-to-client: Web pages can be combined from back-end server output.

User-to-server: uses the information entered by the client to take effect.

A common example of client-to-server communication is the dynamic combination of online forms and some drop-down lists on the server. (usually it requires you to press the button).

The servo-scripting language product has two main parts: the scripting language and the scripting engine (which may or may not be built into the Web server). Engine parts are developed by the same company or team and can only be used in conjunction with each other (PHP3 and ColdFusion are two examples). However, there are exceptions to this rule, for example, Java Server pages is written in standard programming languages rather than scripting languages for specialized purposes; some vendors have developed several compatible interchangeable engines (e.g. Allaire JRun, Apache Jserv).

In theory, Active Server PAGESB allows one of the most common scripting engines with all scripting languages and several matching ActiveX (however, in a substantive job, in addition to nt/iis/vbscript/ Jscirpt's combination, the problem of other combinations is very many), because PHP4 's Scriptingz engine (Zend) is theoretically separated from the PHP programming language, so PHP4 is now considered a separate independent scripting technology.

Figure 2.5 shows an example of a simple servo-scripting language that generates a page from the database based on the server source code and the user-side source code. We included a database call (before Part II of the book, which is not explained in detail at this time), and omitted some of the included files, because the purpose of this example is to display the final finished product of PHP instead of being the original code used by the official job executable

The following is the source code on the server

This is the source code representation of the same page when it arrives at the client:

The above is the PHP learning Treasure-The second chapter of the content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

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