PHP study notes (2): variable details, learning Notes Details _ PHP Tutorial

Source: Internet
Author: User
Tags php operator
PHP study notes (2): variable details and study notes. PHP learning notes (2): variable details, learning notes I. PHP variable introduction 1. syntax copy code: PHP is a weak language, the variable type is determined by the stored value. PHP learning notes (2): variable details, learning Notes Details

I. INTRODUCTION to PHP variables

1. Syntax
The code is as follows:
// PHP is a weak language, and the variable type is determined by the stored value.
// Strong language: int a = 1
$ Variable name = value

2. naming rules

1). cannot begin with a number
2). you cannot use the PHP operator (+-x/% &)
3). you can use the PHP keyword.
4). case sensitive (only variables and constants in php are case sensitive)
5). camper naming method: aaBbCc (the first letter is lowercase)

3. variable

Variable names can be dynamically set, for example: $ var

4. Reference assignment
The code is as follows:
$ A = 1;
$ B = & $ a; // assign the value of the $ a memory address to $ B
$ A = 2;
Echo $ B // the last value is 1

II. Variable Data types

1. four scalar
The code is as follows:
Int (integer), bool (Boolean), float, double (floating point penalty), string (string)

2. compound
The code is as follows:
Array: array ()
Object
Example: $ var = new mysqlli ('localhost', 'root', '123 ')

3. two special types

The code is as follows:
Resource (resource) example: $ var = fopen ('test. php', 'r ')
Null (Null type) is case insensitive

III. common functions

The code is as follows:
Isset () // whether the variable exists. if the value is null, the variable does not exist.
Unset () // release the variable
Var_dump () // check the type of the variable or value
Empty () // returns true if the variable does not exist or is null.
Settype ($ a, int) // Set the variable type
Gettype () // Get the variable type

IV. variable declaration method

The code is as follows:
$ Int = 10 // an integer of 4 bytes. The maximum value is 2 bytes.
$ Float = 3.14E small // float is equal to 3.14X10 small
$ Bool = false // true
$ Str = "string" // variables and escape characters can be parsed in double quotation marks

// Escape characters cannot be used, but single quotation marks can be escaped. for example, $ str = 'a \''
$ Str = 'string'

Declare a string using a delimiter

Explain (2): variable details, learning Notes 1. PHP variable introduction 1. syntax code: // PHP is a weak language, and the variable type is determined by the stored value...

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.