PHP script block with <? Start with php and start with?> End. You can place PHP script blocks anywhere in the document.
Of course, you can use <? And?> To start and end the script block.
However, to achieve the best compatibility, we recommend that you use the standard form (<? Php), rather than the abbreviated form.
Copy codeThe Code is as follows:
<? Php
?>
PHP files usually contain HTML tags, like an HTML file and some PHP script code.
Below, we provide a simple PHP script, which can output the text "Hello World" to the browser ":
Copy codeThe Code is as follows:
<Html>
<Body>
<? Php
Echo "this is PHP tutorial network! ";
?>
</Body>
</Html>
Each line of code in PHP must end with a semicolon. A semicolon is a Separator Used to differentiate the instruction set.
There are two basic commands for outputting text through PHP: echo and print. In the above example, we use the echo statement to output the text.
Comments in PHP
In PHP, we use // to write single-line comments, or use/* and */to write large comments.
Copy codeThe Code is as follows:
<Html>
<Body>
<? Php
// This is a comment
/*
This is a big comment,
Comment multiple lines
*/
Echo "test string1 ";
Echo "<br/>"; // Add "<br/>" Here to generate a new line on the Web page, that is, line feed.
Echo "<br/> ";
// Echo "test string2 <br/> ";
// Echo "test string3 <br/> ";
Echo "test string4 <br/> ";
?>
</Body>
</Html>