使用settype()函数。 http://php.net/manual/zh/function.settype.php 示例:$type = 'int'; $var = '20'; settype($var, $type); var_dump($var);