PHP First Day

Source: Internet
Author: User

PHP tags

1.<?php?> (recommended)

2.<script language= "PHP" ></script>

3.<?>

4.<%%>

PS: Third and fourth need to be opened in PHP config file to use

PHP Comments:

Single-line Comment

Multi-line comments

Document comments

PHP variables

Variable names are case-sensitive

The variable name must be preceded by a letter or underscore, and then made up of a number, letter underline

You cannot have special characters in the middle of a variable name except underline

Cannot use keywords and reserved words

The variable name is defined in $ and does not need to declare the data type of the variable

Assignment of PHP variables

Value assignment $a = ' Hello '

Reference value $b = $ $a;

Variable $demo = ' Hello '; $ $demo = ' world '; = = ${$demo} = $hello = ' World ';

PHP Hyper-Global variables

$_server $_post $_get $_cookie

PHP Constants

Constants are values that cannot be modified throughout the script

Constants use the Define function to define

1. Constant name: General constants are uppercase

2. Value: The value of a constant cannot be modified once defined

Constants are divided into two types: Custom constants, built-in constants

Built-in constants are constants and magic constants defined by the system default

System-defined constants:

Eg:1. M_PI:

Operating system where the 2.php_os:php executes

3.php_version:php version

4. Maximum value of the php_int_max:php integer

PS: These are the common system-defined constants for PHP comparison

Magic constants: In fact, only the form of constants. But there is no constant "constant", its value will actually change, is only a few of the few:

Eg:1._file_ the current script path

2._line_ currently in the row

3._function_ the name of the current function

4._class_ Current class name

5._method_ the name of the method inside the current class

PHP double quotes and single quotes and delimiters

Single quote: Parse fast

Double quotes: Variables inside double quotes can be replaced

Delimiter: The variable inside the delimiter can be replaced, but there must be no space in the end line where the delimiter is located. eg

$demo 3 = <<<dof
$demo ASDASD
Sdfdg
Dfgfdgdgdf
DOF;

DOF: Custom Name

There must be no space behind the DOF.

Data Types for PHP variables

1. Overall Division:

There are 8 data types in PHP

1. Basic type (scalar type)

    1. Integer type: int integer.
    2. Floating-point type: Float,double,real.
    3. String: string;
    4. Boolean type: Bool,boolean

2. Composite type:

1. Array type

2. Objects: Object

3. Special types

    1. Empty type: null, such a type has only one data, that is null.
    2. Resource type: resource, such as a connection resource for a database.

PHP First Day

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.