PHP Data data type
Learned PHP for a long time, but has been on the PHP resource conversion is not very clear, see and Java, but after I looked carefully, found that there are a lot of different, then I would like to talk about PHP in my own learning experience:
First, we all know that PHP is a weakly typed language? (because any one variable can be saved to a variable that starts with $, so, say PHP is a weak type of language, but not that it cannot specify the data type, just save the way special), data type?
What data type: Refers to a certain data structure with a particular operation defined on the data structure to make up some kind of datatype.
So you know PHP has a variety of data classes, Integer, Integer, Float, String, Boolean, array type, object type, resource type, NULL type, simple type (scalar data type), a data to save a value; but sometimes we don't know every one of these places. To deepen your understanding, then summarize:
1 There is a limit to the maximum amount of storage space that can be used by an integral type.
An integral type occupies 4 bytes (byte)
One byte = 8 bits (bit, bit)
Need to use one representation symbol, highest bit (31), 0 positive, 1 negative
The number can be expressed using PHP's predefined constant, Php_int_max, if the number continues to increase in size, then it becomes a floating-point number,
2 If you look closely you will find that the absolute value of the minimum is greater than the absolute value of the maximum number (the complement is determined by the computer, the bitwise operation is considered again)
3.
PHP supports three binary representations when defining integer data (representing a number that can be in three forms--------------------decimal, octal, hexadecimal
Octal: Starts with 0.
Hex: 0x begins.
Decimal: General!
Emphasize that 0 or 0x is not part of a number, just PHP is a syntax for distinguishing between different binary types!
4. Manual conversion into the system
Rule: decimal number, divided by target binary. Will get the remainder and quotient. If the quotient is not zero, continue to use the quotient divided by the target system, and obtain the remainder and quotient. Until the quotient is zero, all the remainder is connected from the bottom down:
Functions commonly used in the program
dec,10
bin,2
oct,8
hex,16
Decbin (); 10to2
Dechex (); ten to 16
Octdec (); 8 to 10
5 floating point
PHP's floating-point numbers do not differentiate between single-precision and double-precision, and PHP only achieves double precision. The floating-point number of PHP is double precision.
1) floating-point number support scientific notation method
2) valid digits 14 digits that PHP can represent
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
}
The cause of the problem:
When a decimal is saved, it needs to be turned into binary. There are few numbers that can be fully expressed.
How to convert decimals to 2 binary came David:
Multiply by 2, take the integer part:
All floating-point numbers are stored in approximate values, not exact values.
6 Boolean type
Represents the true and false of a logical relationship
7. Composite data type, one data save multiple values
Arrays, objects
8 Special types
Null type
http://www.bkjia.com/PHPjc/900031.html www.bkjia.com true http://www.bkjia.com/PHPjc/900031.html techarticle PHP Data Type learning PHP for a long time, but has been on the PHP resource conversion is not very clear, see the same as Java, but after I looked carefully, found that there are still a lot of different ...