PHP | is_string() Function Last Updated : 27 Apr, 2020 Suggest changes Share Like Article Like Report The is_string() function is an inbuilt function in PHP which is used to check whether the given value is a string or not. Syntax: bool is_string( mixed $var ) Parameters: This function accepts one parameter as mentioned above and described below: $var: It contains the value that need to check. Return Value: It returns TRUE if the value of variable is of string type and FALSE otherwise. Program 1: php <?php $str = "GeeksforGeeks"; // Check value of variable is set or not if(is_string($str)) { echo "String"; } else { echo "Not String"; } $arr = array(10, 25.56, 'G', true, 'Geeks'); foreach ($arr as $index) { if(is_string($index)) { echo "\nString"; } else { echo "\nNot String"; } } ?> Output: String Not String Not String String Not String String Program 2: php <?php $num = 21; var_dump(is_string($num)); $arr = array( "a" => "Welcome", "b" => 2, "c" => "GeeksforGeeks" ); var_dump(is_string($arr["a"])); var_dump(is_string($arr["b"])); var_dump(is_string($arr["c"])); ?> Output: bool(false) bool(true) bool(false) bool(true) Reference: https://www.php.net/manual/en/function.is-string.php Advertise with us Next Article PHP | is_string() Function A ashokjaiswal Follow Similar Reads PHP String Functions Strings are a fundamental data type in PHP, used to store and manipulate text. PHP provides a wide variety of built-in string functions. These functions perform various operations such as string transformations, character manipulations, encoding and decoding, and formatting, making string handling s 6 min read PHP strspn() Function The strspn() function is an in-built function in PHP which finds the length of the initial segment of a string consisting entirely of characters contained within a given list of characters passed as a parameter to the function. Syntax : strspn( $string, $charlist, $start, $length) Parameters : This 3 min read PHP strlen() Function The strlen() is a built-in function in PHP which returns the length of a given string.It calculates the length of the string including all the whitespaces and special characters. Syntax:strlen($string);Parameters: This parameter represents the string whose length is needed to be returned. Return Val 1 min read PHP is_scalar() Function PHP_scalar() function is an inbuilt function in PHP and is used to check whether a variable is a scalar or not. Syntax: bool is_scalar ( $var ) Parameter: This function accepts a single parameter as shown in the above syntax and described below. $var: Variable to check if it is a scalar or not. Retu 1 min read PHP trim() Function The trim() function in PHP is an inbuilt function which removes whitespaces and also the predefined characters from both sides of a string that is left and right. Related Functions: PHP | ltrim() Function PHP | rtrim() Function Syntax: trim($string, $charlist) Parameters:The function accepts one man 2 min read Article Tags : Web Technologies PHP PHP-string PHP-function Like