Home >Backend Development >PHP Tutorial > 字符串转成 数值计算的有关问题

字符串转成 数值计算的有关问题

WBOY
WBOYOriginal
2016-06-13 12:54:58863browse

字符串转成 数值计算的问题
$num1="1";
$num2="3"
$str="*"

要得出 1*3=3
即:$res=$num1如何$str如何$num2=3
用什么方法


------解决方案--------------------
$res= eval("return $num1$str$num2;");<br />
var_dump($res);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn