The PHP script can be placed anywhere in the document.
The PHP script begins with <?php and ends with ?> :
<?php//here is the PHP code?>
The default file name extension for PHP files is ". php".
PHP files usually contain HTML tags and some php script code.
The following example is a simple PHP file that contains a PHP script that uses the built-in PHP function "echo" to output text "Hello world!" on a Web page:
Instance
<! DOCTYPE html>
Note: The PHP statement ends with a semicolon (;). The close tag of a PHP block also automatically indicates a semicolon (so you don't have to use a semicolon in the last line of the PHP block).
Comments in PHPComments in the PHP code are not read and executed as programs. Its only function is for code editors to read.
Comments are used to:
Make others understand what you're doing-comments can let other programmers know what you're doing at each step (if you work for a team)
Remind yourself of what you've done-most programmers have gone through a year or two to rework a project and then have to rethink what they've done. Comments can record the way you think when you write code.
PHP supports three types of annotations: instance
<! DOCTYPE html>
PHP Case SensitiveIn PHP, all user-defined functions, classes, and keywords (such as if, else, Echo, and so on) are not case sensitive.
In the example below, all of these three-day echo statements are legal (equivalent):
Instance<! DOCTYPE html>
In PHP, however, all variables are case-sensitive.
In the following example, only the first statement shows the value of the $color variable (because $color, $COLOR, and $coLOR are treated as three different variables):
Instance<! DOCTYPE html>
This article is from the "God of the North Wind blog" blog, please be sure to keep this source http://dovemoon.blog.51cto.com/9968338/1618329
Basic PHP syntax