The data type of php. I have been learning php for a long time on the data type of php, but I still don't know much about php resource conversion. I can see it is similar to java, but after careful consideration, we found that there are still many different php Data types.
I have been learning php for a long time, but I have never understood the resource conversion of php. I have seen it is similar to java. but after careful reading, I found that there are still many differences, so let me talk about my own learning experience in php:
First, we all know that php is a weak language? (Because any variable can be saved to a variable starting with $, php is a weak language, but it does not mean that it cannot specify the data type, only the storage method is special), data type?
What data type: refers to a certain data structure and special operations defined on the data structure constitute a certain data type.
We know that php has various data classes, such as integer, integer, floating point, string, Boolean, array, object, resource, and NULL, A simple type (a scalar data type) stores a value for one piece of data, but sometimes we may not know about each of these. To deepen your understanding, we will summarize the following:
1. the maximum storage space that integer data can use is limited.
An integer occupies 4 bytes)
One byte = 8 bits (bit)
One digit is required to represent the symbol. The highest bit (31), 0 is positive, and 1 is negative.
This number can be represented by php's predefined constant PHP_INT_MAX. if the number continues to increase, it will become a floating point number,
2. if you observe it carefully, you will find that the absolute value of the minimum value is greater than the absolute value of the maximum number (determined by the complement computer, which should be considered during bitwise operations)
3.
When defining integer data, php supports three hexadecimal representations (representing a number, which can be in the format of ---------------- decimal, octal, and hexadecimal ).
Octal: starts with 0.
Hexadecimal: starting with 0x.
Decimal: normal!
It is emphasized that 0 or 0x is not a part of the number, but php is just a syntax for distinguishing different Hexadecimal formats!
4. manual conversion
Rule: decimal number, divided by the target base. The remainder and operator are obtained. If the operator is not zero, continue to divide the operator by the target system to obtain the remainder and operator. Until the operator is zero, connect all the remainder from the bottom to the bottom:
Common functions in the program
Dec, 10
Bin, 2
Oct, 8
Hex, 16
Decbin (); 10to2
Dechex (); 10 to 16
Octdec (); 8 to 10
5 floating point number
Php's floating point number does not distinguish between single precision and double precision. php only achieves double precision. Php floating point number is double precision.
1) floating point supportScientific notation
2) valid Php numbers14 digitsValid number
3) comparison of floating point numbers cannot be compared with floating point numbers.
For example:
If (1-0.2 = 0.8) {// output true
}
If (1-0.8 = 0.2) {// output false
}
Cause:
When the decimal point is saved, it must be converted to binary. It can be expressed completely.
How to Convert decimal points into a binary representation:
Take the integer part of the product by multiplying 2:
All floating point numbers are saved as approximate values rather than exact values.
6 Boolean
Indicating true or false logical relationships
7. Composite data type. multiple values are saved for one data.
Array, object
8 Special types
NULL type
I have been learning php for a long time, but I have never understood the resource conversion of php. I saw it is similar to java. but after careful reading, I found that there are still many differences...