Basic PHP knowledge-1. Basic syntax, basic knowledge basic syntax

Source: Internet
Author: User

Basic PHP knowledge-1. Basic syntax, basic knowledge basic syntax

To be continued ......

I. Introduction to PHP

 

Ii. PHP development environment Configuration

 

Iii. PHP syntax

1. PHP scripts can be placed anywhere in the document? Php, starting with?> End:

<? Php // here is the PHP code?>

The default file extension for PHP files is ". php"

<!doctype html>

2. PHP three annotation Methods

<! DOCTYPE html> <body> <? Php // This is a single line comment # this is also a single line comment/* multiple lines comment block across multiple lines */?> </Body> 

3. Case sensitivity in PHP

In PHP, all user-defined functions, classes, and keywords (such as if, else, and echo) are case insensitive.

<! Doctype html> 

Iii. PHP Variables

1. Create a variable

Php creates a variable without a keyword. A variable is created when it is assigned a value for the first time and starts with the $ symbol and is followed by the variable name;

2. variable scope

Local: variables declared within the function have LOCAL scopes and can only be accessed within the function.

Global: variables declared outside the function have a Global scope and can only be accessed outside the function.

 

Static scope (static): static scope has a static scope when the function is destroyed or deleted after it is executed, and the variable still exists after the function is executed.

3. variable naming rules (PHP variable names are case sensitive !)

  • The variable starts with the $ symbol, followed by the variable name
  • The variable name must start with a letter or underscore
  • The variable name cannot start with a number.
  • Variable names can only contain letters, numbers, and underscores (A-z, 0-9, and _)
  • Variable names are case sensitive ($ y and $ Y are two different variables)

Data Type

Operator

Process Control

 

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.