In php four data types
- Boolean
- Integer
- Float
- String
This data type can represent either true or false . In PHP value is 1 and value of false doesn’t any value.
is_bool : Using this function , we can check input variable is boolean or not.
(bool) var OR (boolean) var using this function , we convert variable into boolean variable.
This data type can store numeric value
is_int OR is_integer it is used to cheak input variable is integer or not .
(int)var ))OR (integer) var OR intval(var) Using this function , we convert variable into integer variable.
this data type can store decimal values .
is_float () this function cheacks input variuable is float or not.
(float)var Converts a variable into floating point number.
It is a collection of character.
In PHP , we can declar string in three ways.
- By using single quotations
- By using double quotations
- By using heredoc syntax
NOTE Variable in double quotations returns value of variables.
Heredoc PHP suports heredoc syntax to avoid the conflicts what we getting with single and double quotations.
Compound data types
- Array :- Array is a collection of heterogenous elements .
- Object :- Object is an instance of class.
Special Data type
Resource :- This data type can refer external resoures like database connections , file pointers etc.
Null data types :- In PHP , null is not a value . we can consisder a varible as null variable based on three conditions.
- if variable is not set with any value.
- if variable is set with null .
- if variable’s value is unset.
is_null() Using this function , we can check input variable is null or not .
- Strlen() to get length of string.
Note :- Ord() used for getting ASCII value
- strtoupper() ;- Converts all character of a string into uppercase .
- strto lower() : Converts characters of a string into lower case .
- ucfirst(): Converts first characters of string into upper case .
- ucwords(): Converts first character of all words into upper case .
- nl2br() : to break new lines of string.
- Str_word_count() : To get total number of words of a string .
- We can pass node value, if node value is 0. It returns total no of words.
- If node value is 1, It returns each word as array elements has a numeric key 0,1,2. Etc.
- If node value is 2, It returns each word as array element. Keys are the index numbers of words
- Strip_tags() : To strip HTML of a string .
- Htmlspecialchars(): To stop the execution of html tags.
- Addslashes() : To add escape slashes (backslashes /) in front of single and double quotations.
- Stripslashes() : To remove the slashes , which we added with add slashes function ( addslashes())
- Str_replace() : To replace a string with the new string .
- Strchr() : To get substring of input string from specified characters .
- Strrchr(): Same as strchr(0 but it scarches the specified character from reverse direction of string.
- Strstr() : It is same as strchr() , to get substring of a string from specified characters.
- Stristr() : same as strstr() but it is case insensitier.
- Similar_text() : To get no of similarities between two strings.
Time() :
- To get current date and time information as time stamp value . Time stamp is total no of seconds from 1970 jan 1 12:00am
- Date() : this function converts time stamp value as date, method and year format string.
Characters supported by date()
- D : 2-digit date number with leading 0 .
- J : A number without leading ) (date number).
- D : 3-characters day name (Mon, Tue, etc)
- L : full day name .
- m : month no without 0.
- n : : month no without 0.
- M : month name with 3-characters (Aug , sep, etc)
- F : full month name .
- y: 2-digit year no.
- y : 4-digit year no
- h: 12-hour format with leading 0
- H: 24-hour format with leading 0
- g: 12-hour format without 0
- G : 24 hour format without 0
- i : minutes
- s : seconds
- a: lower case am/pm.
- A : upper case am/pm
- w: day no in a week from 0 to 6
- N : day no a week from (1-7)
- W: no of completed weeks in current year
- e: country date format , to get time zone of server .
- p : to get GMT value of server (%+5 :30)
Getdate() To get current date and time information as array .
Checkdate(): To check input date is existent or not