$var = "Hello";
$type = gettype($var);
echo $type; // 输出string
$var = 123;
if(gettype($var) == 'integer'){
echo "This is an integer.";
} else {
echo "This is not an integer.";
}
class MyClass {}
$obj = new MyClass();
if($obj instanceof MyClass){
echo "This is an instance of MyClass.";
} else {
echo "This is not an instance of MyClass.";
}
$var = "Hello";
var_dump($var); // 输出string(5) "Hello"
$var = "123";
$intVar = (int)$var;
echo $intVar; // 输出123