PHP data types

1.String
2.Integer
3.Floating point numbers
4. Boolean
5. Array 
6.object
7. NULL

PHP Strings 

• A string is a sequence of characters, like "Hello world!". 
• A string can be any text inside quotes. You can use single or double quotes: 

Example 

<?php 
$x = "Hello world!";
echo $x; 
echo "<br>"; 
$x = 'Hello world!'; 
echo $x; 
?> 

PHP Integers 

• An integer is a number without decimals. 
• Rules for integers: 
- An integer must have at least one digit (0-9) 
- An integer cannot contain comma or blanks 
- An integer must not have a decimal point 
- An integer can be either positive or negative 
- Integers can be specified in three formats: decimal (10-based), hexadecimal 
(16-based - prefixed with 0x) or octal (8-based - prefixed with 0) n
$x=10 , $y=1abc0x 

PHP Floating Point Numbers 

• A floating point number is a number with a decimal point or a number in exponential 
form. 
• In the following example we will test different numbers. The PHP var_dump()
function returns the data type and value of variables: 

Example 

<?php 
$x = 10.365; 
var_dump($x); 
?> 

PHP Booleans 

• Booleans can be either TRUE or FALSE. 
o $x=true; 
o $y=false;

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post