Build a database-driven website using PHP and MySQL (4)
Source: Internet
Author: User
Summary
In this chapter, we will introduce the script language of the PHP server. We will see that this language supports communication with the MySQL database.
(14:10:52)
--------------------------------------------------------------------------------
By Wing, source: Linuxaid
Chapter 3: Getting started with PHP
In the previous chapter, we learned how to use the MySQL database engine to store a joke list in a simple database (containing only one data table called Jokes. At that time, we entered the SQL command (query statement) through the command line on the MySQL client. In this chapter, we will introduce the script language of the PHP server. We will see that this language supports communication with the MySQL database.
PHP introduction
As we mentioned earlier, PHP is a server-side scripting language. This concept may be hard to understand, especially if you have used HTML and JavaScript to design web pages. A server-side scripting program is similar to JavaScript in many places, both of which allow you to insert some programs (scripts) in the HTML on the web page ). The result is that these scripts allow you to control what will be displayed in the browser window, which is obviously much more flexible than using HTML directly.
The key difference between JavaScript and PHP is that when a Web browser interprets JavaScript, the Web page containing the script has been downloaded. For server-side scripting programs such as PHP, the work explained is completely done by the server before the page is sent to the browser. After the explanation is complete, the PHP code on the Web page will be replaced by the script running result, and the viewer will see a standard HTML file. Scripts are completely processed by the server. This is the origin of its naming: server-side scripting.
Let's look back at the example today. php we created in Chapter 1:
<HTML>
<HEAD>
<TITLE> Today's Date </TITLE>
</HEAD>
<BODY>
<P> Today's Date (according to this Web server) is </p>
<? Ph
Echo (date ("l, F dS Y ."));
?>
</BODY>
</HTML>
Most of this program uses HTML format. Only the middle row is written in PHP.
End PHP code ". Before sending the Web page to the browser requesting it, the Web server processes all the content before the two identifiers and converts them into standard HTML code. The page received by the browser will be as follows:
<HTML>
<HEAD>
<TITLE> Today's Date </TITLE>
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