Advanced Java and Web Technologies for JNTUK
Blog providing beginner tutorials on different web technologies like HTML, CSS, Javascript, PHP, MYSQL, XML, Java Beans, Servlets, JSP and AJAX
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.

Categories: PHP. No Comments on Datatypes in PHP
0
(0)

PHP provides four scalar types namely Boolean, integer, double and string and 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.


Subscribe to our monthly newsletter. Get notified about latest articles, offers and contests.


 

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.

 

A video tutorial on data types in PHP:

 

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Suryateja Pericherla

Suryateja Pericherla, at present is a Research Scholar (full-time Ph.D.) in the Dept. of Computer Science & Systems Engineering at Andhra University, Visakhapatnam. Previously worked as an Associate Professor in the Dept. of CSE at Vishnu Institute of Technology, India.

He has 11+ years of teaching experience and is an individual researcher whose research interests are Cloud Computing, Internet of Things, Computer Security, Network Security and Blockchain.

He is a member of professional societies like IEEE, ACM, CSI and ISCA. He published several research papers which are indexed by SCIE, WoS, Scopus, Springer and others.

Note: Do you have a question on this article or have a suggestion to make this article better? You can ask or suggest us by filling in the below form. After commenting, your comment will be held for moderation and will be published in 24-48 hrs.

Leave a Reply

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