Home > Backend Development > PHP Tutorial > PHP judgment variable type implementation code_PHP tutorial

PHP judgment variable type implementation code_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:43:15
Original
767 people have browsed it

PHP includes several functions that can determine the type of variables, such as: gettype(), is_array(), is_float(), is_int(), is_object() and is_string().

Copy code The code is as follows:

$s = "this is a string";
$i = 9;
$arr = array(2,4,6);
is_string($s); //Return TRUE, indicating that $s is a string variable
is_string($ i); //Returns FALSE, indicating that $i is not a string variable
is_array($arr); //Returns TRUE, indicating that $arr is an array
is_array($s); //Returns FALSE, Indicates that $s is not an array
$str = "this is a string";
$int = 9;
$bool = FALSE;
echo "The type of $str is: ".gettype( $str);
echo "
";
echo "
";
echo "The type of $int is: ".gettype($int);
echo "
";
echo "
";
echo "The type of $bool is: ".gettype($bool);
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320751.htmlTechArticlePHP includes several functions to determine the type of variables, such as: gettype(), is_array(), is_float() , is_int(), is_object() and is_string(). Copy the code The code is as follows: ?php $s = "th...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template