oa Happy dual mode data type conversion -PHP

It refers to the data conversion value (variable) data to the target type.
OA credit tray erecting q3191355031
PHP There are two types of data conversion: automatic conversion, cast

Automatic conversion: system variable is the value corresponding to the type of conversion according to the type of operation required for
automatic conversion system itself things are done, the user does not need to intervene.

Cast: according to our specific needs, the value of the variable in advance converted into the desired data type
int, integer: integer, converting the data into an integer
bool, Boolean: convert the data into a Boolean value
float: converted to float -point
string: converted into character
array: into an array type of
object: Object type converted

Syntax :( data type) variable
view the data type of way
1.var_dump the type and length as well as variable data values are output
2. Type gettype function by function, access to data, returns a string
write here Picture Description

Set the data type: settype ($ var, 'type') "========" (type) $ var
here to write picture description
written here describe pictures

Conversion: automatic conversion and coercion
here to write picture description

String transfer integer
written here describe pictures

Automatic around: string transfer value
written description herein pictures
rules are as follows
1. Only when the string decimal values or start the system until it is possible to convert numeric string, or else directly converted into 0
2. Read Only front continuous value, no other special characters or letters
3. a read only decimal
4. If decimal final retention, the type of data into floating-point, integer otherwise

Analyzing Data Type
PHP provides a series of functions to determine the type of data. Functions are beginning is_, followed by the data type.
If this is the type of target returns TRUE, otherwise returns FALSE
is_bool
of is_float
is_integer
is_object
is_array
is_string
is_resource
is_scalar: to determine whether the value of a variable is a scalar type
is_null
is_numeric: whether a variable is a number or a numeric string
writing picture described here

Guess you like

Origin blog.51cto.com/14524882/2436966