PHP Data Types
Datatypes in PHP:
In this chapter we will discuss datatypes in php, as you learn about the PHP Variables topic “a variable is used to store the value”. So here question arises what is the value that stored in the variable? Is it a number, some alphabets, or couple of alphabets, a value with decimal notation as far as the length of value that we are going to store in a variable? For all these things or values there’s php data types used for: –
Integer in PHP
Float in PHP
String in PHP
What is an Integer in php datatype?
Integer in PHP is basically used to store the numerical values with no decimal notation. (like if you want to store age of a person in year’s 35 you can use integer for it). A very important thing about integer datatype in php there’s a range of integer data type (-2,147,483,648 and 2,147,483,647). So if value exceed from this range it will not be stored in integer.
Integer datatype in php code example | How to use integer in php?
Output of Integer Datatype in php
value of a is:35
$a is a variable which holds the value 35. In echo we pass text in double quotation then use variable to display integer value.
Important Things About Integer Datatype You Must Keep in Your Mind While Using Integer: –
Integer must take one digit at least.
Integer not have to store any decimal value.
Integer can be positive or either negative value or values.
What is float datatype in PHP?
Float Datatype in PHP purpose is store the values with exponent or floating point. A value having point in it (10.4) is floating point number it is stored in float datatype.
How to use float datatype in php | php datatype(float) code example
Output of float datatype in php:
Explanation of float datatype code in php.
We make a variable for first which named as $a and stored value with decimal point ($a=20.5;) then var_dump function is used to display the value stored with datatype in variable.
Note: what is var_dump function in php?
var_dump is use to return the datatype and value.
String datatype in PHP
A string Datatype in php is used to store the combination of characters. Simply string is the concatenation of alphabets. In PHP double or sometimes single quotes are used. String, text came inside quotations marks.
How to use string datatype in php | String Datatype code in php example.
The output of string PHP datatype
Welcome To WorldViewIT PHP Tutorials
Code Example Explanation in String Datatype in PHP
$a is a variable that holds the value ( and the value this time for this variable is a string). $a= “Welcome To WorldViewIT PHP Tutorials” is assigning the value to variable. Echo is used to display the value in output.
- test file
- What is 1XBET | Download 1XBET | Affiliate Program 1XBET | Mobile App for ios & android
- Best electronics gadgets of all time on Amazon’s and eBay
- Internship base Short Courses
- CTI JOBS in Punjab Pakistan | 2019-2020
- Google is turning Android Phones into seismometers
- How independence day of Pakistan Celebrated?
- How Scorpion Venom Effects
- Maecenas nec venenatis
- Suspendisse vel eros nulla