Table of Contents [1] Code identification [2] note [3] output [4] calculation expression [5] case before casing
PHP is a powerful server-side scripting language for creating dynamic, interactive sites. PHP can contain text, HTML, CSS, and PHP code, executed on the server, and returned to the browser in plain text.
Code Identification
PHP code begins with <?php, ends with?>, and can be placed anywhere in the document
<? PHP //?>
The PHP statement ends with a semicolon (;), and the close tag of the PHP code block automatically indicates the semicolon
<? PHP " Hello world! " ;? >
Comments
PHP supports three types of annotations, including two single-line comments and one multiline comment
<? PHP // This is a single-line comment #这也是单行注释 /* This is a multiline comment block that spans multiple lines */?>
Output
In PHP, there are two basic output methods: Echo and Print
Print can output only one string, and always returns 1
Echo is capable of outputting more than one string, and echo is slightly faster than print because it does not return any value
[Note that both]echo and print are language structures, with either echo or Echo (), as well as print or print (), with or without parentheses, and at least one space between the echo or print keyword and the string
<?php echo""; Echo"Hello world!<br>"; Echo"I ' m about to learn php!<br>"; Echo" This","string"," was","made","With multiple parameters.";?>
<?PHP Print""; Print"Hello world!<br>"; Print"I ' m about to learn php!<br>"; //The row is faulted because print can only output 1 stringsPrint" This","string"," was","made","With multiple parameters.";?>
Evaluating Expressions
Unlike HTML and CSS, you can write calculation expressions in PHP
<? PHP // $ *3;? >
Uppercase and lowercase
In PHP, all user-defined functions, classes, and keywords are case insensitive, but all variables are case-insensitive
<? PHP // Hello world! " Hello world!<br> " ; // Hello world! " Hello world!<br> " ; // Hello world! " Hello world!<br> " ;? >
<?PHP $color="Red"; //My car is redEcho"My Car is". $color."<br>"; //My House isEcho"My House is". $COLOR."<br>"; //My Boat isEcho"My Boat is". $coLOR."<br>";?>
Basic grammar of the front-end learning PHP