1.强制转换 不会改变原值的数据类型。
<?php
$num1 = '100';
// 默认为string
echo gettype($num1),'<br/>';
// 强制转换
(int)$num1;
// 在输出$num1,数据类型仍是string
echo gettype($num1),'<br/>';
2.settype() 会改变原值的数据类型。
<?php
$num2 = '200';
// 默认为string
echo gettype($num2),'<br/>';
// 强制转换
settype($num2, 'int');
// 在输出$num2,数据类型变成了int
echo gettype($num2),'<br/>';