Home  >  Article  >  Backend Development  >  PHP data types and conversion PHP data types PHP has several data types What are the PHP data types

PHP data types and conversion PHP data types PHP has several data types What are the PHP data types

WBOY
WBOYOriginal
2016-07-29 08:49:101157browse

Data type

Integer
Floating point type
Boolean type
String
Array
Object

Conversion between types

(int)$val; Convert to integer type
(float)$val; Convert to floating point type
( string)$val; Convert to string
(bool)$val; Convert to Boolean type
(array)$val; Convert to array, the array only contains one element $val. [$val]
(object)$val; Convert to an object, the scalar attribute of the object points to $val. {scalar:$val}

Get the type

Use the function string gettype($val); to get the variable type
The return value of this function is array, boolean, double, integer, object, resource, string, NULL and unknown type.
In addition, you can also use the following functions to determine the variable type
is_array(val); is_bool(val); is_float(val); is_integer(val); is_null(val); is_numeric(val); is_object(val); is_resource(val) ; is_scalar(val); and is_string(val);

PHP super global variable

$_SERVER Contains browser and server related data
$_GET Contains GET data in url request
$_POST Contains POST data in url request
$_COOKIE Contains browser COOKIE data
$_SESSION Used to access SESSION data
$_FILES Contains file upload data
$GLOBALS Contains all global variables

The above introduces PHP data types and conversions, including data types and PHP content. I hope it will be helpful to friends who are interested in PHP tutorials.

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