Exforsys.com
 
Home Tutorials PHP
 

PHP Tutorials - Data Types

 
Category: PHP
Comments (0)

PHP Tutorials - Data Types

In this PHP Tutorial you will learn about PHP Data Types viz. Numeric values, String values, Boolean values, Arrays, Objects and NULL.



Numeric values:

There are two numeric values in PHP, they are:


1. integer: Integer numbers don’t have floating point, for example, 5, 12, 1567


2. real: or floating point numbers, real number has a floating point, for example, 2.3


There are three ways to represent the numeric values:


1. base 10 numbers: They are represented using digits from 1 to 9, with an optional (.) for floating point if the value is real.


2. base 8 numbers: They are represented by preceding the number by zero ‘0’, and it only permits the digits from 0 to 7, example 023, which is the same as 19


3. base 16 numbers: They are represented by preceding zero and x ‘0x’, and it permits the digits from 0 – 9 and characters from ‘A’ to ‘F’, for example, 0x3f, which is the same as 63


String values:

String values are sequence of characters, included in a single quote or double quotes, for example,


This is a string’.


The value inside the quotes are not modified, so if you want to use quotes inside the string, then they have to be escaped, we escape characters in PHP by using backslash,


for example,


She wrote: \’PHP is easy to learn\’’.


The quote is not the only special character that can be escaped, other characters that can be escaped are:


\n Line feed
\r Carriage return
\t Tab
\\ Backslash
\” Double quotes


For example,


This is \n a string”, this will evaluate to:


This is
a string


Boolean values:

Boolean values are true or false, also 0 and empty string evaluates to false, and any numeric value rather than zero, or a string that is not empty evaluates to true.



Arrays:

An array is a collection of elements of heterogeneous type, arrays will be explained later.


Objects:

An object is a collection of data and code, you will learn about Objects later in a seperate tutorial.


NULL:

NULL means no value. It does not contain any meaningful data.



Read Next: PHP Tutorials - Variables



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape