PHP Data Types
Today i will teach you. how we can use PHP data types.
There are Seven types of PHP Data Types.
Example of String Data types:-
Hello PHP
Welcome to PHP
Integer Data type:-Integer is a basic data types. We can assign which has no of fractional part to int type but int is a 2 Byte space.
Importants Rules:
Integer is a least one digit (0-9).
Integer cannot contain comma or blanks.
Integer must not have a decimal point.
Integer can be either positive or negative values.
Now we can assign a value between the above range below example. In this example we have used different variables like as negative number, hexadecimal number ,octal numbers and we have used PHP var_dump(); function returns the data type.
Example
int(4567)
int(-254)
int(140)
int(39)
Today i will teach you. how we can use PHP data types.
There are Seven types of PHP Data Types.
- String.
- Integer.
- Floating point numbers,
- Boolean.
- Array.
- Object.
- NULL.
Example of String Data types:-
<html> <head> <title>String data type</title> </head> <body> <?php $x= "Hello PHP"; $y= "Welcome to PHP"; echo $x; echo "<br>"; echo $y; ?> </body> </html>Output
Hello PHP
Welcome to PHP
Integer Data type:-Integer is a basic data types. We can assign which has no of fractional part to int type but int is a 2 Byte space.
Importants Rules:
Integer is a least one digit (0-9).
Integer cannot contain comma or blanks.
Integer must not have a decimal point.
Integer can be either positive or negative values.
Now we can assign a value between the above range below example. In this example we have used different variables like as negative number, hexadecimal number ,octal numbers and we have used PHP var_dump(); function returns the data type.
Example
<html> <head> <title>Integer Data types</title> </head> <body> <?php $y = 4567; var_dump($y); echo "<br>"; $y = -254; // negative number var_dump($y); echo "<br>"; $y = 0x8C; // hexadecimal number var_dump($y); echo "<br>"; $y = 047; // octal number var_dump($y); ?> </body> </html>Output
int(4567)
int(-254)
int(140)
int(39)
No comments:
Post a Comment