Hello to all of you, thanks for landing on the TutorialPath.com, which is “Your Path to Learn Everything” in an easy way and you can learn almost every sort of important elements about online things. As you land here, so we can assume, you are a newbie for PHP Data Types language, so you don’t need to worry about it.
Welcome to all our readers on our website at www.tutorialpath.com. As you all know that here on our website we will provide you lots of information related to the latest and newly introduced technology which help you to get updated with the latest tech. Here you will get all the useful information which is required in this tech world. As you know technology is one of the trending part in this world. So, here again we came up with a latest and new tech information which is related to the process of creating Basic PHP Data Types for Beginners. With the help of this article you will get to know the complete process of how to create Basic PHP Data Types for Beginners in a step by step manner. So, simply have a look to this article and grab all the useful information which is going to be very helpful for you.
PHP Data Types
- PHP data types are used to hold different types of data or values.
- Data types specify the size and type of values that can be stored.
- PHP is a Loosely Typed Language so here no need to define data type.
PHP supports 8 primitive data types that can be categorized further in 3 types:
- Scalar Types
- Compound Types
- Special Types
PHP Data Types: Scalar Types
There are 4 scalar data types in PHP.
PHP Data Types: Compound Types
There are 2 compound data types in PHP.
PHP Data Types: Special Types
There are 2 special data types in PHP.
Integer : Integers hold only whole numbers including positive and negative numbers, i.e., numbers without fractional part or decimal point. They can be decimal (base 10), octal (base 8) or hexadecimal (base 16). The default base is decimal (base 10). The octal integers can be declared with leading 0 and the hexadecimal can be declared with leading 0x. The range of integers must lie between -2^31 to 2^31.
Double: Can hold numbers containing fractional or decimal part including positive and negative numbers. By default, the variables add a minimum number of decimal places.
PHP Strings: Strings are sequences of characters, where every character is the same as a byte.
A string can hold letters, numbers, and special characters and it can be as large as up to 2 GB (2147483647 bytes maximum). The simplest way to specify a string is to enclose it in single quotes (e.g. ‘Hello world!’), however you can also use double quotes (“Hello world!”).
Boolean: Booleans are like a switch it has only two possible values either
1 (true) or
PHP Array: 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.
Objects: Objects are defined as instances of user defined classes that can hold both values and functions. This is an advanced topic and will be discussed in details in further articles.
Resources: Resources in PHP are not an exact data type. These are basically used to store references to some function call or to external PHP resources. For example, consider a database call. This is an external resource.
PHP Floating Point Numbers or Doubles: Floating point numbers (also known as “floats”, “doubles”, or “real numbers”) are decimal or fractional numbers