PHP, converting data types, judging data types

Source: Internet
Author: User

1.php conversion data type methods are cast and function-converted:

Casting is simply preceded by the variable with the type name enclosed in parentheses.

A functional conversion is a bool Settype (mixed var, string type). The parameter var is the specified variable; The parameter type is the specified data type. The parameter type has 7 optional values, Boolean,float,integer,array,null,object and string. If the conversion succeeds, the Settype function returns True, otherwise false. When a string is converted to an integer or float, if the string starts with a number, the numeric part is converted to shaping, and the subsequent string is removed, and if the number contains a decimal point, it is taken to the previous decimal place.

2. Detection data type:

Is_bool: Detecting whether a variable is a Boolean type

Is_string: Detecting whether a variable is a string type

Is_float/is_double: Detects if a variable is a floating-point type

Is_integer/is_int: Detects if the variable is shaping

Is_null: Detecting whether a variable is a null value

Is_arrary: Detects if a variable is an array

Is_object: Detects if a variable is an object type

Is_numeric: Detects whether a variable is a number or a string consisting of a number

PHP, converting data types, judging data types

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.