Slide 1
Most trusted JOB oriented professional program
DevOps Certified Professional (DCP)

Take your first step into the world of DevOps with this course, which will help you to learn about the methodologies and tools used to develop, deploy, and operate high-quality software.

Slide 2
DevOps to DevSecOps – Learn the evolution
DevSecOps Certified Professional (DSOCP)

Learn to automate security into a fast-paced DevOps environment using various open-source tools and scripts.

Slide 2
Get certified in the new tech skill to rule the industry
Site Reliability Engineering (SRE) Certified Professional

A method of measuring and achieving reliability through engineering and operations work – developed by Google to manage services.

Slide 2
Master the art of DevOps
Master in DevOps Engineering (MDE)

Get enrolled for the most advanced and only course in the WORLD which can make you an expert and proficient Architect in DevOps, DevSecOps and Site Reliability Engineering (SRE) principles together.

Slide 2
Gain expertise and certified yourself
Azure DevOps Solutions Expert

Learn about the DevOps services available on Azure and how you can use them to make your workflow more efficient.

Slide 3
Learn and get certified
AWS Certified DevOps Professional

Learn about the DevOps services offered by AWS and how you can use them to make your workflow more efficient.

previous arrow
next arrow

PHP 7 Fundamental Tutorial for Beginners – PHP Data Types

Spread the Knowledge

The name itself indicating, data types means type of data.

The values assigned to a PHP variable may be of different data types including simple string and numeric types to more complex data types like arrays and objects.

PHP supports total of eight primitive data types: Integer, Floating point number or Float, String, Booleans, Array, Object, resource, and NULL. These data types are used to construct variables. Now let’s discuss each one of them in detail.

Types of data types in php:

PHP data types are mainly divided into 3 types:

  • Scalar Data Types: integer, string, Floating-Point Numbers or Doubles, Boolean
  • Composite Data Type: array, object
  • Special Data Types: Null, resource

Scalar Data Types: allow us to create variables or constants; which can hold a single value.

Integer: means whole number, i.e. number without floating point

Ex: 122, 2000, -400 etc.

Double: Means decimal or float number, i.e. number containing floating Point.

Ex: 3.142, 9.8, -48.32 etc.

String: indicates a sequence of characters enclosed within pair of double quotations or single quotations i.e. Textual data.

Ex: “Hello world” , ‘Hello JavaScript’ etc.

Boolean: indicates logical or conditional result Boolean data type has two values true and false value.

Note:
integers 0 and -0, double 0.0 and -0.0, string with value “, string with value “0”, Boolean false value, an array with zero elements, the special type NULL, and XML objects created from empty tags, are considered as false in PHP.

Example:

PHP Arrays

An array is a variable that can hold more than one value at a time. It is useful to aggregate a series of related items together, for example, a set of country or city names.

An array is formally defined as an indexed collection of data values. Each index (also known as the key) of an array is unique and references a corresponding value.

Example:

PHP Objects

An object is a data type that not only allows storing data but also information on, how to process that data. An object is a specific instance of a class which serve as templates for objects. Objects are created based on this template via the new keyword.

Every object has properties and methods corresponding to those of its parent class. Every object instance is completely independent, with its own properties and methods, and can thus be manipulated independently of other objects of the same class.

Here’s a simple example of a class definition followed by the object creation.

Example:

Special data Types: allow us to make a variable point to some external resource or not to point anywhere.

NULL: indicates nothing.
A variable of type objects points or refers to another memory location; if it should not point to any memory location then we assign a value null to it.

Example:

When a variable is created without a value in PHP like $var; it is automatically assigned a value of null. Many novice PHP developers mistakenly considered both $var1 = NULL; and $var2 = “”; are same, but this is not true. Both variables are different — the $var1 has null value while $var2 indicates no value assigned to it.

PHP Resources

Indicates variable is pointing to an external resource

A resource is a special variable, holding a reference to an external resource.

Resource variables typically hold special handlers to opened files and database connections.

Example:

Dharmendra K
Latest posts by Dharmendra K (see all)