Stupid birds Learn PHP (ii) How to use variables

Source: Internet
Author: User
Tags float double
Stupid birds Learn PHP (ii) How to use variables

I. Declaration of variables

1. methods of declaring variables in PHP: $var = 123;

2. PHP is a weakly typed language, and the type of the variable is determined by the stored value

Note: Java is a strongly typed language, declaring a variable must first specify the type

3. Isset () and unset ()

Isset (): Determine whether the value exists; Unset (): Remove the value of the variable

 
  

Two. Naming of variables

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

2. You cannot start with a number.

3. Cannot use the arithmetic symbol in PHP +-*/% &

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

5. Only variables and constants in PHP are case-sensitive, others do not differentiate


Two. Variable variable

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

 
  
2. Variable can be referenced assignment (and a reference in Java)

 
  

Three. Types of variables

1. As mentioned earlier, PHP is a weakly typed language, and its type is determined by the stored value

2. PHP has 8 types:

2.1) Four kinds of scalars:

Shape: int integer Boolean: bool Boolean float: float double real string: string

2.2) Two types of composite

Array: Array object: Object

2.3) Special types in two

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?>

Four. Variable declarations of various types

 
  






  • 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.