Explain about data type using php - In the previous article I have discussed about variables in php, then in this article we will discuss about the type of data in php. In PHP, the variable data type is not defined by the programmer, but is automatically determined by the PHP interpreter. However, PHP supports 8 (eight) primitive data types, namely:
Description: The sample program handles some basic data types within PHP.
Here is an example of a data type program.
Type the following php code into notepad:
<?php
$number = "0411500400";
$name = 'Johans Supri';
$age = 23;
$value = 82.25;
$status = TRUE;
echo "Number : " . $number . "<br>";
echo "Name : $name<br>";
print "Age : " . $age; print "<br>";
printf ("Value : %.3f<br>", $value);
if ($status)
echo "Status : Active";
else
echo "Status : Not active";
?>
If it is saved in the htdocs folder, name it type.php
Then run the program by opening the browser then type in address bar http: //localhost/type.php then enter. Then the result will look like the following.
That's the article about explain about data type using php. Hopefully the article can be useful for you. Please learn and practice so you can better understand it.
- Boolean: Boolean Data Type in PHP is the simplest data type that is only two conditions that is True atai False.
- Integer: An integer data type is used to store integers containing positive and negative integers or no fraction values.
- Float: Double Floating type is also called double, float or real is the data type used to store decimal numbers.
- String: The data string type is a data type consisting of a word, either a single word or a sentence.
- Array: The array or array data type is the data type used to overwrite a lot of data in a single variable.
- Object: The object data type in php is created for OOP based programming (Oriented Programming Object).
- Resource: Resource Data Type is so special because it can store resource, source or address.
- NULL: Null Data Type Is a Data Type that does not contain anything.
Description: The sample program handles some basic data types within PHP.
Here is an example of a data type program.
Type the following php code into notepad:
<?php
$number = "0411500400";
$name = 'Johans Supri';
$age = 23;
$value = 82.25;
$status = TRUE;
echo "Number : " . $number . "<br>";
echo "Name : $name<br>";
print "Age : " . $age; print "<br>";
printf ("Value : %.3f<br>", $value);
if ($status)
echo "Status : Active";
else
echo "Status : Not active";
?>
If it is saved in the htdocs folder, name it type.php
Then run the program by opening the browser then type in address bar http: //localhost/type.php then enter. Then the result will look like the following.
Program View |
That's the article about explain about data type using php. Hopefully the article can be useful for you. Please learn and practice so you can better understand it.
This is a amazing post. This article is good . For more detail in briefly click here
ReplyDeleteHOW TO DEFINE DATA TYPE IN PHP