Stupid bird learning php (2) how to use variables

Source: Internet
Author: User
Tags float double
Stupid bird learning php (2) how to use variable 1. variable Declaration 1. methods for declaring variables in php: & nbsp; $ var123; 2. php is a weak language, and the variable type is determined by the stored & #20540; & nbsp; note: Java is a strong language, to declare a variable, you must first specify the type 3. isset () and unset () & nbsp; is stupid bird learning php (2) how to use variables

I. variable declaration

1. method for declaring variables in php: $ var = 123;

2. php is a weak language, and the variable type is determined by the stored value.

Note: Java is a strongly-typed language. to declare a variable, you must specify the type first.

3. isset () and unset ()

Isset (): determines whether a value exists; unset (): removes the value of the variable.

 

2. variable naming

1. you must use "$" before the variable. this symbol must be included in the declaration and use.

2. it cannot start with a number.

3. you cannot use the operator number in php +-*/% &

4. you can use the system keyword as the variable name.

5. in php, only variables and constants are case-sensitive, while others are case-insensitive.


2. variable

1. the variable name of a variable can be dynamically set and used

 
2. variables can be referenced and assigned values (one with the reference in Java)

 

III. types of variables

1. as mentioned earlier, php is a weak type language and its type is determined by the storage value.

2. php has 8 medium types:

2.1) four scalar:

Integer: int integer boolean: bool boolean floating point: float double real string: string

2.2) two composite types

Array: array object: object

2.3) two special types

Resource Type: resource null type: null

 int(1) [1]=>int(2) [2]=>int(3)}$var=new mysqli("localhost", "root", "root", "newcms");var_dump($var); // object(mysqli)#1(0){}$var=fopen("1.php", "r");var_dump($var); // resource(3) of type (stream)$var=null;var_dump($var); // NULL?>

IV. declaration of various types of variables

 






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.