$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