The online tutorials on the PHP site have been great. This section of this article will give you a bit of familiarity with PHP. I can not do without any omission, my purpose is to let you quickly start your PHP programming.
3.1 First-order conditions
You must first have a Web server that is working to support PHP. I assume that all PHP files on your server have an extension of. php3.
Installation of 3.2 PHP
For the installation configuration of PHP, you can check the Web page of the "PHP Installation full Introduction" feature article.
3.3 Grammar
Syntactically, the PHP language is similar to the C language. It can be said that PHP is to learn from the grammatical features of C language, from the C language to improve. We can mix PHP code and HTML code, not only embed PHP scripts into HTML files, we can even embed HTML tags in PHP scripts. Here are a few ways you can use it. You can choose one of the most suitable for you and stick to this method!
Detach from HTML
The following are the methods you can use:
? . . . ? >
<?php ...? >
<script language= "php" > ... </script>
<% ...%>
Note: When you use "." . . . ? > "Embedding PHP code in an HTML file may conflict with XML, and the ability to use this reduction depends on the settings in PHP itself." To accommodate XML and other editors, you can add "PHP" to the beginning of the question mark to adapt the PHP code to the XML parser. such as: "<?php ...?" > ". You can also use script tags like other scripting languages, such as: "<script language=" php > ... </script>.
Statement
Like Perl and C, ";" is used in PHP to separate statements. The flags that are separated from the HTML also represent the end of the statement.
Comments
PHP supports c,c++ and UNIX-style annotation methods:
The simplest interaction between PHP and HTML is done through the print and ECHO statements, and in practice, the print and ECHO functions are almost identical. It can be said that there is a place to use, and the other can be used. However, there is also a very important difference: in the Echo function, you can output multiple strings at the same time, whereas in the print function you can output only one string at a time. Also, the Echo function does not require parentheses, so the echo function is more like a statement than a function. Let's take a look at the following example:
After viewing this code in the browser, you will see the results of this operation:
Aba
Parse error:parse Error in d:adminmyphphometest.php3 on line 5
This means that the code is not fully explained, where the error occurs in line fifth of the code: "Print" A "," B ";".
3.4 A simple example
With the knowledge we've learned, you can write one of the simplest program outputs, one of the most famous words in the program world.
<HTML>
<HEAD>
<TITLE>
?
echo "Hello world!";
?>
</TITLE>
</HEAD>
<BODY>
<H1>
The I-PHP page
</H1>
<HR>
?
Single line C + + style Comment
/*
Printing the message
*/
echo "Hello world!";
# Unix Style single line comment
?>
</BODY>
</HTML>
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.