PHP gettype() Function

PHP gettype() Function

The gettype () function in PHP gets the type of the specified variable.

Syntax

gettype ( mixed $var ) 

Parameter

var(required)- This parameter represents the variable being type checked.

Return

This function returns the type of the PHP variable specified by “var” parameter.

The possible returned values are as follows:

  • Boolean
  • Integer
  • Double
  • String
  • Array
  • Object
  • Resource
  • Null

Example 1

 

Output

false is a boolean value
13 is a integer value
51.16 is a double value
Abc3462 is a string value 

Example 2

 

Output

It is an array value
It is an object value
It is a NULL value
It is a resource value 

Example 3

 

Output

string
integer
double
double  

Related Topics

PHP is_double() Function

The PHP is_double() function in PHP is used to  find whether the type of the specified variable is a float or not. It returns a Boolean value true if the parameter var is...

1 minute read.

PHP str_getcsv() Function

PHP str_getcsv() Function The str_getcsv() function in PHP parses a CSV string into an array and returns an array containing the fields read. Syntax str_getcsv ( string $input [, string $delimiter [, string $enclosure [, string$escape ]]] ) Parameter input(required)- This parameter represents the string to parse. delimiter(optional)- This parameter signifies...

1 minute read.

PHP sha1_file() Function

PHP sha1_file() Function The sha1_file() in PHP calculates the sha1 hash of a file and returns the hash (40-character hexadecimal number). Syntax sha1_file ( string $filename [, bool $raw_output] )  Parameter filename(required)- This parameter represents the filename of the file to hash. raw_output(optional)- This...

1 minute read.

PHP array() function

PHP array() function The array() function in PHP is used to create an array. Syntax array ([ mixed $... ] ) Parameter …(optional)- This parameter represents the elements’ values along with keys of the array. The syntax of this is as follows: "index => values"...

1 minute read.

PHP crc32() Function

PHP crc32() Function The crc32() function in PHP  Calculates the crc32 polynomial of a string. Syntax crc32( string $str ) Parameter str(required)- This parameter represents The string to be calculated Return This function returns the crc32 checksum of string as an integer. Example 1 ...

1 minute read.

PHP strip_tags() Function

PHP strip_tags() Function The strip_tags() function in PHP is sued to strip a string from HTML, XML, and PHP tags. It is a binary-safe function. Syntax strip_tags ( string $str [, string $allowable_tags ] ) Parameter str(required)- This parameter specifies the input string. allowable_tags(optional)- This parameter represents...

1 minute read.

PHP foreach Loop

PHP foreach Loop with Example PHP foreach loop is used to loop through the associative arrays. Syntax: foreach($array as $key => $value) { //Statement } $array = associative array. $key = array key. &value =...

2 minutes read.

PHP Forms

PHP form is used to take input from users, by using superglobals$_REQUEST, $_GET and $_POSTmethod. There are various request methods in PHP Get method Post method Put method Patch method Delete...

5 minutes read.

PHP array_intersect_ukey() function

The array_intersect_ukey () function in PHP is used to compute the intersection of arrays with the help of a callable function on the keys for comparison. It returns an array containing all the...

1 minute read.

PHP stripos() Function

PHP stripos() Function The stripos() function in PHP finds the position of the first occurrence of a substring in the specified string. It is a case-insensitive a binary-safe function. The related functions are as follows: strripos() Functionstrpos() Functionstrrpos() Function Syntax stripos ( string $haystack , mixed $needle [, int $offset...

1 minute read.

PHP array_values() Function

PHP array_values() Function The array_values () function in PHP returns all the values from the array and indexes the array numerically. Syntax array_values ( array $array ) Parameter array(required)- This array represents the input array. Return This function returns an indexed array of values. Example 1 Output Input Array: Array ...

1 minute read.

PHP strtr() Function

PHP strtr() Function The strtr() function in PHP translates or replaces certain characters in a string. Syntax strtr ( string $str , string $from , string $to ) or strtr ( string $str , array $replace_pairs ) Parameter str(required)- This parameter specifies the string to translate from(required)- This parameter represents the string being translated to the parameter ‘to’. to(required)- It specifies what...

1 minute read.

PHP For Loops

PHP for loop is used when the specified condition is predefined. Syntax: for (initialization; condition; increment/decrement ) { code to be executed; } Example <!DOCTYPE html> <html> <head> <title>PHP Tutorial</title> </head> <body> <?php echo " Print counting using for loop"."<br>"; for($i=1;$i<=5;$i++){ echo $i."<br>"; } ?> </body> </html> Output Print counting using...

1 minute read.

Composer Installation

Composer is an application-level package manager for the PHP Programming language. The development began in April 2011 and it was first released on March 1, 2012. Commands: require install update remove Installation:  Download the installer by visiting...

1 minute read.

PHP in_array() Function

PHP in_array() Function The in_array() function in PHP checks if the value exists in the specified array or not. Syntax in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )  Parameter needle(required)- This parameter represents the searched value. haystack(required)- This parameter represents the input array. strict(optional)- This parameter...

1 minute read.

PHP uasort() Function

PHP uasort() Function The uasort() function in PHP sorts an array with a user-defined comparison function and maintains the index association. Syntax uasort ( array &$array , callable $value_compare_func ) Parameter array(required)- This parameter represents the input array. value_compare_func(required)- This parameter represents a string that describe a...

1 minute read.

PHP Array Functions

There are various array functions in PHP. They are used to access and manipulate the elements ofan array. Following are functions of array. Array Function Description array() It is used to create an array. array_change_key_case() It is...

3 minutes read.

PHP array_diff_assoc() Function

PHP array_diff_assoc() Function The array_diff_assoc() Function in PHP compares the difference of arrays and returns an array containing all the values from array1 that are not present in any of the other arrays. Syntax array_diff_assoc ( array $array1 , array $array2 [, array $... ] ) Parameter array1(required)- This parameter signifies...

1 minute read.

PHP array_map() Function

PHP array_map() Function The array_map() function  in PHP is used to return an array containing the results of applying the user-defined callback function over the elements of one or more arrays. Syntax array_map ( callable $callback , array $array1 [, array $... ] )  Parameter callable(required)- This parameter...

1 minute read.

PHP convert_cyr_string() Function

PHP convert_cyr_string() Function The convert_cyr_string() function in PHP converts from one Cyrillic character-set to another. The supported characters set are given below: k - koi8-rw - windows-1251i - iso8859-5a - x-cp866d - x-cp866m...

1 minute read.