我想做这样的事情:
$type = "int"; $casted = ($type)$value;
这不起作用。但是还有其他方法可以转换为动态确定的类型吗?
谢谢
发布于 2018-09-29 12:50:08
使用该settype()功能。
settype()
http://php.net/manual/en/function.settype.php
例:
$type = 'int'; $var = '20'; settype($var, $type); var_dump($var);
https://stackoverflow.com/questions/-100002803
相似问题