Use of PHP variables

Source: Internet
Author: User

If you use the data, you need to use the declaration as a variable more than once;

Declaration of a variable

$ Variable name = value

In strongly typed languages (C,java), declaring variables must first specify the type (wine bottle)

PHP is a weakly typed language: The type of the variable is determined by the stored value. Bottle

2.Isset function to determine whether a variable exists

3.unset function Release variables

Name of the variable

1. Be sure to use "$" before the variable, declare and use this symbol

2. Cannot start with a number

3. You cannot use PHP's arithmetic symbols (+-*/% &.)

4.PHP can use the System keyword as the variable name

5. Note: PHP variables are case-sensitive (only variables and often case-sensitive, others do not differentiate)

6. Variable names must be meaningful, you can use English words, you can also use Hanyu Pinyin.

Variable variable

1. Variable names for a variable can be set and used dynamically.

Assigning a reference to a variable

Use a "&" symbol to precede the variable that will be assigned (note)

Types of variables

PHP is a weak type of language

PHP has 8 types.

14 Scalar types

Integral type: int integer

Boolean: BOOL Boolean

Float type: float, double,real

2. Two types of composite

Arrays: Array

Objects: Object

3. Two special types

Resource type: Resource

NULL type: null

Var_dump (variable or value);//You can view a variable or a worthwhile type, and you can see the data

Variable declarations of various types

1. $int = 10; Decimal Declaration

2. $int = 045; octal declaration

3. $int =0xff; Hex Declaration

The maximum value of an integer 4 bytes 2 of 32 times, 214483647

1. $folat =10

2. $folat =-10

3. $folat =3.14e5

4. $folat =3.15e+5

5. $folat =5.14e-2//e can be capitalized or lowercase

It's all a false case.

$bool =false;

$bool = 0;

$bool = 0.00;

$bool = "";

$bool = "";

$bool =null;

$bool = "0";

$bool =array ();

There are several ways to declare a string

$str = ' aaaaaaaaaaa ';

$str = "AAAAAAAAAAA";

1. Both single and double quotation marks can declare a string

2. The declared string has no length limitation

3. In a double-quoted string, you can either parse the variable directly or use the escape character directly

4. In a single-quoted string, you cannot parse a variable or use an escape character (you can escape the single quotation mark itself, or you can escape the character "\")

5. You cannot use double quotation marks in double quotation marks, no time single quotes in single quotation marks

6. It is best to use single quotation marks

Delimiter Declaration string

Use of PHP variables

Related Article

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.