Basic grammar of the front-end learning PHP

Source: Internet
Author: User
Tags learn php

Directory

[1] Code identification [2] note [3] output [4] calculation expression [5] case

Previous words

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

The PHP code ends 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 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

[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    "

PHP is fun!

" ; " Hello world!
" ; " I ' m about to learn php!
" ; " This " " string " " was " " made " " With multiple parameters. " ;? >

 
  PHP    "

PHP is fun!

" ; " Hello world!
" ; " I ' m about to learn php!
" ; // The row is faulted because print can only output 1 strings " 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!
" ; // Hello world! " Hello world!
" ; // Hello world! " Hello world!
" ;? >

[note]. The number represents a string connection, in other programming languages, usually with the + sign

 
  php    $color ="red";     // My car is red    " ""
" ; // """
" ; // My boat is " ""
" ;? >

The above introduces the basic grammar of the front-end PHP, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.