The gettype() function is an inbuilt function in PHP which is used to get the type of a variable. It is used to check the type of existing variable.
string gettype ( $var )
Parameter: This function accepts a single parameter $var. It is the name of variable which is needed to be checked for type of variable.
Return Value: This function returns a string type value. Possible values for the returned string are:
- double (for historical reasons “double” is returned in case of float)
- unknown type
Below programs illustrate the gettype() function in PHP:
boolean integer double string array object NULL resource
string integer integer double double
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.