PHP Basic Learning process

Source: Internet
Author: User

1. Basic knowledge

A. NOTES:

<? PHP // This is a single-line comment # This is also a single-line comment /* This is a multiline comment block that spans multiple lines of */?>

B. Case sensitive:

In PHP, all user-defined functions, classes, and keywords (such as if, else, Echo, and so on) are not case sensitive.

In PHP, however, all variables are case-sensitive.

C. Variables:

<? PHP $x=5;   // Defining Variables $y=6; $z=$x+$y; Echo $z;  // Output Variable ?>
PHP Variable rules:
    • The variable starts with the $ sign, followed by the name of the variable
    • Variable names must begin with a letter or underscore
    • Variable names cannot start with a number
    • Variable names can contain only alphanumeric characters and underscores (A-Z, 0-9, and _)
    • Variable names are case sensitive ($y and $Y are two different variables)

Note: The PHP variable name is case-sensitive!

<?PHP$x= 5;//Global ScopefunctionmyTest () {$y= 10;//Local Scope  Echo"Variable:</p> inside the <p> test function"; EchoThe variable x is:$x"; Echo"<br>"; EchoThe variable y is:$y";} MyTest ();Echo"Variable:</p> outside of the <p> test function";EchoThe variable x is:$x";Echo"<br>";EchoThe variable y is:$y";?>
PHP Variable Scope

In PHP, variables can be declared anywhere in the script.

The scope of a variable refers to the part of the script that a variable can be referenced/used.

PHP has three different scope of variables:

      • Local (partial)
      • Global (globally)
      • Static (statically)

PHP Basic Learning process

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.