Home / Programming / PHP / 6. Detailed Explanation of PHP Data Types

6. Detailed Explanation of PHP Data Types

/
/
/
180 Views

This session, I will explain in detail about PHP Data Types. Variables contained in PHP can store data of different types, and different data types can do different things. The concept of variables in PHP is actually almost the same as other programming languages.

But to be more complete, PHP supports the following data types:

  • String
  • Integer
  • Float (floating point numbers – also called double)
  • Boolean
  • Array
  • Object
  • NULL
  • Resource

PHP String

A string is an arrangement of characters, similar to “Hello world!”.

A string can be any content inside statements. You can utilize single or twofold statements. Example is :

PHP Integer

A whole number information type is a non-decimal number between – 2,147,483,648 and 2,147,483,647.

Rules for numbers:

  • A number must have at any rate one digit
  • A number must not have a decimal point
  • A number can be either positive or negative
  • Numbers can be determined in: decimal (base 10), hexadecimal (base 16), octal (base 8), or double (base 2) documentation

In the accompanying model $x is a number. The PHP var_dump() work restores the information type and worth. See the example below:

PHP Float

A buoy (skimming point number) is a number with a decimal point or a number in exponential structure.

In the accompanying model $x is a buoy. The PHP var_dump() work restores the information type and worth. See the example below:

PHP Boolean

A Boolean represents two possible states: TRUE or FALSE.


Booleans are regularly utilized in restrictive testing. You will become familiar with restrictive testing in a later part of this instructional exercise.
Recommended  2. How to Install Apache, MySQL and PHP in Ubuntu 18.04 LTS Part 1

PHP Array

An array stores multiple values in one single variable.

In the following example $cars is an array. The PHP var_dump() function returns the data type and value. See the example below:


You will become familiar with much progressively about clusters in later parts of this instructional exercise.

PHP Object

An article is an information type which stores information and data on the most proficient method to process that information.

In PHP, an article must be expressly pronounced.

First we should proclaim a class of item. For this, we utilize the class watchword. A class is a structure that can contain properties and techniques. See the example below:

PHP NULL Value

NULL is an exceptional information type which can have just one worth: NULL.

A variable of information type NULL is a variable that has no worth relegated to it.

Tip: If a variable is made without a worth, it is consequently allocated an estimation of NULL.

Factors can likewise be exhausted by setting the incentive to NULL. See the example below:

PHP Resource

The uncommon asset type isn’t a real information type. It is the putting away of a reference to capacities and assets outer to PHP.

Recommended  5. PHP Echo and Print Statements

A typical case of utilizing the asset information type is a database call.

We won’t discuss the asset type here, since it is a propelled theme.

  • Facebook
  • Twitter
  • Linkedin
  • Pinterest

Leave a Comment

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

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :