PHP: casting to a dynamically determined type
Use the settype()
function.
Example:
$type = 'int';$var = '20';settype($var, $type);var_dump($var);
Use the settype()
function.
Example:
$type = 'int';$var = '20';settype($var, $type);var_dump($var);