What are different datatypes in PHP

Follow by Email
Facebook0
Facebook
Google+
https://codingsec.net/2016/11/different-datatypes-php/

PHP provides four scalar types namely Boolean, integer, double and stringand two compound types namely array and object and two special types namely resource and NULL.

PHP has a single integer type, named integer. This type is same as long type in C. The size of an integer type is generally the size of word in the machine. In most of the machines that size will be 32 bits.

PHP’s double type corresponds to the double type in C and its successors. Double literals can contain a decimal point, an exponent or both. An exponent is represented using E or e followed by a signed integer literal. Digits before and after the decimal point are optional. So, both .12 and 12. are valid double literals.

String is a collection of characters. There is no special type for characters in PHP. A character is considered as a string with length 1. String literals are represented with single quotes or double quotes. In a string literal enclosed in single quotes, escape sequences and variables are not recognized and no substitutions occurs. Such substitution is known as interpolation. In string literals enclosed in double quotes, escape sequence and variables are recognized and corresponding action is taken.

The only two possible values for a Boolean type are TRUE and FALSE both of which are case-insensitive. Integer value 0 is equal to Boolean FALSE and anything other than 0 is equal to TRUE. An empty string and string “0” are equal to Boolean FALSE and remaining other strings are equal to TRUE. Only double value equal to Boolean FALSE is 0.0.

Take your time to comment on this article.

Follow by Email
Facebook0
Facebook
Google+
https://codingsec.net/2016/11/different-datatypes-php/

Add a Comment

Your email address will not be published. Required fields are marked *

Like the article? please consider sharing it. Thank you

Advertisment ad adsense adlogger