is_string
函數(shù)用于檢查一個變量是否為字符串類型,如果是則返回true,否則返回false。其精確使用方法為:
$string = "Hello, world!";
if (is_string($string)) {
echo "Yes, it is a string.";
} else {
echo "No, it is not a string.";
}
上述代碼將輸出"Yes, it is a string.",因為變量$string
的值是一個字符串。