The front-end must learn PHP grammar basics, the front-end PHP syntax
Write it in front.
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
<?phpecho "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 also a single-line comment/* This is a multiline comment block which 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
between Scripts, it's important to note that both Echo and print are language structures, with either echo or Echo (), or print or print (), and a minimum of one space between the echo or print keyword and the string
<?phpecho "PHP is fun!
"; echo" Hello world!
"Echo" I ' m about to learn php!
"; echo" This "," string "," is "," made "," with multiple parameters. ";? ><?phpprint "PHP is fun!
";p rint" Hello world!
";p rint" I ' m about to learn php!
";//The line went wrong because print can only output 1 strings of print" This "," string "," is "," made "," with multiple parameters. ";? >
evaluating expressions
Unlike HTML and CSS, you can write calculation expressions in PHP
<?php//36echo 12*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! ECHO "Hello world!
";//hello World!echo" Hello world!
";//hello world! EcHo "Hello world!
";? >
Help the home friendship reminds everyone to pay attention to the point : . Number for string connection, in other programming languages, General + number
<?php$color= "Red";//my car is Redecho "My car is". $color. "
";//my house was echo" My house is ". $COLOR. "
";//my boat Isecho" My boat is ". $coLOR. "
";? >
The above content is a small series to share the front-end must learn PHP Grammar Foundation, I hope to help you, at the same time thank you all have been to help the home site support, at the same time I wish everyone happy New Year.
Articles you may be interested in:
- PHP Basic Syntax format
- How to check PHP files for syntax errors in PHP
- PHP trim removal null character definition and syntax introduction
- Configure PHP Web page to display various syntax errors
- Summary of basic syntax for PHP regular expressions
- The Vim plugin for automatic PHP grammar checking
- Basic and variable of PHP syntax summary
http://www.bkjia.com/PHPjc/1087269.html www.bkjia.com true http://www.bkjia.com/PHPjc/1087269.html techarticle The front -end must learn PHP syntax base, the front-end PHP syntax written in front of the word PHP is a dynamic interactive site to create a powerful server-side scripting language. PHP can contain text, HTML 、...