The syntax of PHP is very much like the C language.
1, PHP can be mixed with the HTML code, using the format:
<?php
Statement
?>
2, PHP code can also embed HTML code
3, can use JavaScript script to embed PHP code (not recommended)
Like what:
<script language= "PHP" >
echo "Hello";
</script>
4, if only to display the value of a variable, you can use the following methods:
<?= variable?>
Cases:
<title> My php file </title>
<meta http-equiv= "Content-type" content= "TEXT/HTML;CHARSET=GBK"/>
<body>
<?php
$i = 45;
?>
<br/> Results are: <?= $i?>
</body>
Show:
The result: 45
5, the PHP statement ends with a semicolon;
6. PHP is case-sensitive
7, PHP is a weak data type programming language, the type of variable is not fixed.
8. The PHP variable name begins with a letter or an underscore followed by any letter, number, or underscore.
9. When PHP defines variables, use the dollar sign $ identifier.
Cases:
$a = 600; Defines a variable named $a, and then assigns a value of 600 to the variable.
PHP file to run the error of several common English words meaning:
Parse: Parsing
Error: Wrong
Syntax: Grammar
Unexpected: Do not expect
Expecting: Expectation
Comments in PHP
1. Multiple lines of annotation:
/*
Code
......
*/
2. Comment Single line:
Code
#代码