One, PHP script code tag
PHP script is a special tag in the file included in the content, such as ASP is "<%....%>", PHP can be seen as " ”。
However, in order to adapt the XML standard to embed PHP into XML or XHTML, PHP does not recommend using the short format " ", and we recommend using long format tags. ”
In addition, the PHP code block also supports the form of markup.
Second, PHP instruction delimiter
Each statement in PHP needs to be separated by a semicolon ";", but for the PHP end tag "?>", there is no need to append semicolons because it automatically implies a semicolon.
Therefore, the format of a PHP script can be as follows:
/*
............ ;
............ ;
............ ;
............
*/
Note that the last line can have no semicolon
?>
Third, PHP comments
PHP Multi-line comments use "/* ... */"
Single-line comment using "#" or "//"
Four, the output of PHP
Use the "<%=...%>" Quick output line in ASP, or use "<%response.write (...")%> "
Use "echo ()" or "print ()" Directly in PHP, such as:
echo "a";
Echo (b);
Echo ("C");
Echo D;
?>
The output is "ABCD", the above four kinds can be output normally.
But this is in ASP, especially echo "a"; and Echo D; is not possible to export to the string itself. This requires understanding the variable definition of PHP.
Five, PHP variables
Like ASP, PHP variables can be used without first defining them. For the type of the variable, it is automatically generated when the value is assigned.
Various variables in PHP are preceded by the variable name with "$" to differentiate.
$a = "123";
echo A;
echo $a;
?>
Enter as "A123"
Six, single and double quotes in PHP
$a = "123";
echo "$a";
echo ' $a ';
?>
The output is "123$a", where echo "$a" outputs the value of variable A, and echo ' $a ' outputs the string itself in single quotation marks.
$a = "123";
echo "$a ' $a '";
?>
The output as "123 ' 123" is not "123$a". Although it is ' $a ', the variable is replaced with double quotes.
Therefore, it can be concluded that as long as the variables in the contents of the double quotation marks are substituted, the single quotation marks do not make any substitution.
The contents of the double quotes should be escaped, using the "\" prefix, such as "\ \", "\$", "\". So to enter "123$a";
$a = "123";
echo "$a \ $a";
?>
Another example:
$a = "123";
echo "$a \ $a \" \ \ ";
?>
The output is "123$a" \ ".
ASP transfer PHP needs to note:
1, delimiter comma ";" Easy to forget to write.
2, the definition and use of variables.
3, the use of single and double quotation marks.
The above describes the intimate contact PHP PHP Grammar study Note 1, including the content of the article, I hope the PHP tutorial interested in a friend helpful.