B> from a simple program to understand PHP
The online tutorial for the PHP site has been great. This section of this article will let you familiarize yourself with PHP. I could not have done without any omission, and my purpose was only to allow you to quickly start your PHP programming.
3.1 First conditions
You first have to have a working Web server that supports PHP. I assume that all PHP files on your server have a. php3 extension.
3.2 Installation of PHP
For PHP installation configuration, you can check the page pottery bar on the "PHP installation All-in" feature article.
3.3 Syntax
Syntactically, the PHP language is similar to the C language. It can be said that PHP is a reference to C language grammatical features, improved by the C language. We can mix PHP code and HTML code, not only to embed the PHP script into the HTML file, we can even embed HTML tags in the php script. Here are a few ways you can do it. You can choose one of the most suitable and stick to this method!
Detach from HTML
Here are the methods you can use:
$#@60;? . . . ? $#@62;
$#@60;? Php...? $#@62;
$#@60;script language= "PHP" $#@62; ... $#@60;/script$#@62;
$#@60;%.%$#@62;
Note: When you use the "$#@60;?" . . . ? $#@62; " Embedding PHP code in an HTML file may conflict with XML, and the ability to use this form of reduction also depends on the settings of the 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: "$#@60;? Php...? $#@62; ". You can also use script tags like other scripting languages, such as: "$#@60;script language=" PHP "$#@62; ... $#@60;/script$#@62; ".
Statement
As with Perl and C, separate the statements in PHP with ";". Flags that are separated from HTML also represent the end of the statement.
Comments
PHP supports c,c++ and UNIX-style annotation methods:
/* c,c++ style multi-line Comment */
C + + style line Comment
# UNIX Style single line comment
Echo and Print
The simplest interaction between PHP and HTML is achieved through print and ECHO statements, which are almost identical in the actual use of both print and echo. 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 between the two: in the Echo function, you can output multiple strings at the same time, and in the print function you can only output one string at a time. Also, the Echo function does not require parentheses, so echo? More like a statement than a function. Let's take a look at the following example:
$#@60;?
$a = "Hello";
$b = "World";
echo "A", "B";
Print "A", "B";
? $#@62;
With the browser watching the running of this code, you will see this running result:
Aba
Parse error:parse Error in d:adminmyphphomeest.php3 on line 5
This means that the code is not completely explained, where the error occurs on line fifth of the code: "Print" A "," B ";".
3.4 A simple example
With the knowledge that we've learned, you can write a simple program output that's probably the most famous word in the world of programs.
$#@60; html$#@62;
$#@60; head$#@62;
$#@60; title$#@62;
$#@60;?
echo "Hello world!";
? $#@62;
$#@60;/title$#@62;
$#@60;/head$#@62;
$#@60; body$#@62;
$#@60; h1$#@62;
First PHP page
$#@60;/h1$#@62;
$#@60;hr$#@62;
$#@60;?
Single line C + + style Comment
/*
Printing the message
*/
echo "Hello world!";
# Unix Style single line comment
? $#@62;
$#@60;/body$#@62;
$#@60;/html$#@62;
http://www.bkjia.com/PHPjc/531702.html www.bkjia.com true http://www.bkjia.com/PHPjc/531702.html techarticle b> from a simple program to understand the PHP PHP site online tutorial has been great. This section of this article will let you familiarize yourself with PHP. I could not do without any omission, my purpose ...