PHP | is_string() Function Last Updated : 27 Apr, 2020 Comments Improve Suggest changes 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 Create Quiz Comment A ashokjaiswal Follow 0 Improve A ashokjaiswal Follow 0 Improve Article Tags : Web Technologies PHP PHP-string PHP-function Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like