What is PHP
In 1994, PHP was developed by Rasmus Lerdorf. It is a scripting language that can be deployed on the server side. The main advantage of PHP is open-source. For web development, PHP is well fitted. Hence, it is utilized to create dynamic web applications.
PHP Online Course supports PHP learners to build dynamic applications under the guidance of real-time mentors.
The following points are important about PHP:
- PHP doesn’t require compilation.
- Compares with other Scripting languages. PHP is quicker.
- PHP is used to handle the dynamic content of the web application.
- PHP be able to integrate into HTML.
- PHP is an object-oriented and interpreted scripting language that is an easy-to-learn.
PHP is majorly categorized into three different data type in php and it supports 8 primitive data types.
- Predefined Types
- User-defined
- Special Types
Predefined Types
It comprises a single value but this value contains 3 Predefined
data types.
- string
- Integer
- boolean in php
Compound Types
It comprises 2 compound data values.
- array
- object
Special Types
PHP Contains 2 special data types.
- Resource
- NULL
PHP String Data Type
It is a non-numeric data type. It contains only alphabets and special characters.
String values should be closed in single quotes or double quotes. But both are handled separately. To understand this, refer this instance below:
Example:
<?php
$company = “FITA Academy“;
//both single and double quote statements will treat different
echo “Hello $PHP Tutorial”;
echo “</br>”;
echo ‘Hello $PHP Tutorial’;
?>
Output:
FITA Academy
Hello $PHP Tutorial
To know more about different Data Type In PHP, Check PHP Training in Chennai.
Boolean In PHP Data Type
It’s the most uncomplicated data type that acts like a switch button. It includes two states: TRUE (1) or FALSE (0). It is frequently used depending on statements. If the statement is correct, it returns TRUE otherwise FALSE.
Example:
<?php
if (TRUE)
echo “The statement is TRUE.”;
if (FALSE)
echo “The statement is FALSE.”;
?>
Output
The statement is TRUE.
PHP Array Data Type
It is a compound types and comprises many values of identical data type in a separate variable.
Example:
<?php
$cars = array (“Honda”, “BMW”, “Toyota”);
var_dump($cars); //the var_dump() function returns the datatype and values
echo “</br>”;
echo “Array Element1: $cars[0] </br>”;
echo “Array Element2: $cars[1] </br>”;
echo “Array Element3: $cars[2] </br>”;
?>
Output:
array(3) { [0]=> string(13) “Honda” [1]=> string(6) “BMW” [2]=> string(3) “Toyota” }
Array Element1: Honda
Array Element2:BMW
Array Element3:Toyota
PHP object Data Type
Objects data types are the examples of user-specified classes which can save values and functions. They should be clearly stated.
Example:
<?php
class car {
function model() {
$model_name = “Maruti Suzuki”;
echo “Car Model: ” .$model_name;
}
}
$obj = new Car();
$obj -> model();
?>
Output:
Car Model: Maruti Suzuki
Conclusion:
In this blog, we discussed different Data Type with examples. It will be useful for learners and beginners in PHP. If you plan to get training in PHP, PHP Training in Coimbatore is the right destination