Basic grammar of the front-end learning PHP

Source: Internet
Author: User
Tags learn php php print

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.