Home  >  Article  >  Backend Development  >  PHP syntax basics

PHP syntax basics

高洛峰
高洛峰Original
2016-11-17 09:26:171040browse

PHP data types (it is a weakly typed language)

Integer, floating point, Boolean, string, array, object, empty type, resource type

Scalar type: integer, floating point , Boolean and string types! The so-called scalar type is essentially a type that can only store a single item of information.

Composite type: array, object. The essence of composite types is that they can store multiple pieces of information!

Special types: empty type and resource type


All types are stored in binary form in the computer!


Conversion from decimal to binary:

Convert decimal to binary: multiply by 2 and round up

Convert ten to eight: divide the integer part by eight and round up, multiply the decimal part by eight and round up

Convert octal to binary and can be split in one step Three:

Convert binary to octal and merge three into one:

Convert hexadecimal to binary and split into four:

Convert binary to hexadecimal and merge four into one:

Convert eight to sixteen: First One is divided into three and converted into two, and then four and one are converted into sixteen:

Sixteen to eight: One is divided into four and converted into two, and then three and one are converted into eight


Exponent form:

required A few points to note:

1, e is not case-sensitive

2, there must be numbers before and after e

The back of e must be an integer


integer data is stored in its binary format in the memory It is stored in the form of two's complement!

The original code, inverse code, and complement of a positive number (sign is 0) are the same.

The inverse code of a negative number (sign is 1) is based on the original code. Except for the sign bit, the rest is unchanged. Bitwise inversion,

The complement of a negative number = its complement + 1

Convert to Boolean type, the following types will be converted to false:

Integer type 0:0

Floating point 0:0.0

String 0: '0'

Empty string:''"

Empty type: NULL

Empty array: array()


Resource type and object type are always true!


Characters in PHP The difference between single and double quotes:

Single quotes: cannot recognize variables and escape characters

Double quotes: can recognize variables and escape characters

Delimiter:

Syntax: <<记 Content 束 Ending the mark; Type

settype() sets the type of the variable

isset() determines whether the variable exists

empty() determines whether the variable is empty


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn